#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ concurrent_get_num_products(int *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void *count_products_thread(void *arg) {
  char *product;
  int num_products;
  product = (char *)malloc(strlen((char *)arg));
  strcpy(product, (char *)arg);
  printf("Thread %s \n", product);
  concurrent_get_num_products(&num_products);
  free(product);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<count_products_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1070 <printf@plt>
lea    -0x1c(%rbp),%rdi
call   1040 <concurrent_get_num_products@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_products_thread>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <strlen@plt>
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
lea    0x4(%rsp),%rdi
call   1040 <concurrent_get_num_products@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <pthread_exit@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Thread %s \0A\00"
define i8* @count_products_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @concurrent_get_num_products(i32* %5)
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = call i32 @pthread_exit(i32* null)
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [12 x i8] c"Thread %s \0A\00"
define noalias i8* @count_products_thread(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcpy(i8* %6, i8* %0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%9 = call i32 @concurrent_get_num_products(i32* %2)
%10 = call i32 @free(i8* %6)
%11 = call i32 @pthread_exit(i32* null)
ret i8* undef
}