MySQL 5.7 C API Developer Guide
my_ulonglong mysql_stmt_insert_id(MYSQL_STMT *stmt)
          Returns the value generated for an
          AUTO_INCREMENT column by the prepared
          INSERT or
          UPDATE statement. Use this
          function after you have executed a prepared
          INSERT statement on a table
          which contains an AUTO_INCREMENT field.
        
See Section 5.4.38, “mysql_insert_id()”, for more information.
          Value for AUTO_INCREMENT column which was
          automatically generated or explicitly set during execution of
          prepared statement, or value generated by
          LAST_INSERT_ID(
          function. Return value is undefined if statement does not set
          expr)AUTO_INCREMENT value.