#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 */
char *construct_insert(char *, char **, char **);
int /*<<< orphan*/ exec_nonquery(char *);
char *format_string(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *strdup(char *);
char *strtok(char *, char *);
void add_assign_task(char *id, char *add) {
  if (add != NULL) {
    char *aux = strdup(add);
    char *temp = strtok(aux, ",");
    char *fields[] = {"NOMBRE_USUARIO_ASIG", "ID_ASIG", 0};
    char *insert = NULL;
    while (temp != NULL) {
      insert = NULL;
      char *user_name = format_string(temp);
      char *values[] = {user_name, id, 0};
      insert = construct_insert("GP_ASIGNACIONES", fields, values);
      exec_nonquery(insert);
      free(insert);
      free(user_name);
      printf("+ Asigned user %s\n", temp);
      temp = strtok(NULL, ",");
    }
  }
}


x86 assembly (clang, -O0):
<add_assign_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     126e <add_assign_task+0xfe>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    0x2c4d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c4a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c47(%rip),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x48(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1269 <add_assign_task+0xf9>
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <format_string@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
lea    -0x40(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe02(%rip),%rdi
call   1080 <construct_insert@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <exec_nonquery@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xda5(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    11d5 <add_assign_task+0x65>
jmp    126e <add_assign_task+0xfe>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_assign_task>:
test   %rsi,%rsi
je     1247 <add_assign_task+0xd7>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
mov    %rsi,%rdi
call   1090 <strdup@plt>
lea    0xe67(%rip),%rsi
mov    %rax,%rdi
call   1070 <strtok@plt>
mov    %rax,%rbx
mov    0x2c65(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2c49(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
test   %rbx,%rbx
je     1239 <add_assign_task+0xc9>
lea    0xe66(%rip),%rbp
lea    0xe31(%rip),%r15
nop
mov    %rbx,%rdi
call   1060 <format_string@plt>
mov    %rax,%r12
mov    %rax,(%rsp)
mov    %r14,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe2a(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1080 <construct_insert@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1050 <exec_nonquery@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <add_assign_task+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [20 x i8] c"NOMBRE_USUARIO_ASIG\00"
@.str.2 = [8 x i8] c"ID_ASIG\00"
@__const.add_assign_task.fields = [3 x i8*] [i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [16 x i8] c"GP_ASIGNACIONES\00"
@.str.4 = [19 x i8] c"+ Asigned user %s\0A\00"
define void @add_assign_task(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [3 x i8*]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [3 x i8*]
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %43
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %6
%18 = bitcast [3 x i8*]* %7 to i8*
store i8* null, i8** %8
br label %19
19: ; preds = %22, %13
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %42
22: ; preds = %19
store i8* null, i8** %8
%23 = load i8*, i8** %6
%24 = call i8* @format_string(i8* %23)
store i8* %24, i8** %9
%25 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
%26 = load i8*, i8** %9
store i8* %26, i8** %25
%27 = getelementptr inbounds i8*, i8** %25, i64 1
%28 = load i8*, i8** %3
store i8* %28, i8** %27
%29 = getelementptr inbounds i8*, i8** %27, i64 1
store i8* null, i8** %29
%30 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
%32 = call i8* @construct_insert(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8** %30, i8** %31)
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = call i32 @exec_nonquery(i8* %33)
%35 = load i8*, i8** %8
%36 = call i32 @free(i8* %35)
%37 = load i8*, i8** %9
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %6
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %41, i8** %6
br label %19
42: ; preds = %19
br label %43
43: ; preds = %42, %2
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [20 x i8] c"NOMBRE_USUARIO_ASIG\00"
@.str.2 = [8 x i8] c"ID_ASIG\00"
@__const.add_assign_task.fields = [3 x i8*] [i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [16 x i8] c"GP_ASIGNACIONES\00"
@.str.4 = [19 x i8] c"+ Asigned user %s\0A\00"
define void @add_assign_task(i8* %0, i8* %1) {
%3 = alloca [3 x i8*]
%4 = alloca [3 x i8*]
%5 = icmp eq i8* %1, null
br i1 %5, label %28, label %6
6: ; preds = %2
%7 = tail call i8* @strdup(i8* %1)
%8 = tail call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = bitcast [3 x i8*]* %3 to i8*
%10 = icmp eq i8* %8, null
br i1 %10, label %27, label %11
11: ; preds = %6
%12 = bitcast [3 x i8*]* %4 to i8*
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 2
%16 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
br label %17
17: ; preds = %11, %17
%18 = phi i8* [ %8, %11 ], [ %25, %17 ]
%19 = call i8* @format_string(i8* %18)
store i8* %19, i8** %13
store i8* %0, i8** %14
store i8* null, i8** %15
%20 = call i8* @construct_insert(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8** %16, i8** %13)
%21 = call i32 @exec_nonquery(i8* %20)
%22 = call i32 @free(i8* %20)
%23 = call i32 @free(i8* %19)
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %17
27: ; preds = %17, %6
br label %28
28: ; preds = %27, %2
ret void
}