#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*/ set_run_var(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char);
void l_setList(int n, char *arg, char *buf, char *thelist) {
  register int i, j;
  for (j = 0, i = 1; i <= n; i++) {
    sprintf(arg + j, "%d,", thelist[i]);
    while (arg[j] != '\0')
      j++;
  }
  if (j > 0)
    arg[j - 1] = '\0';
  set_run_var(buf, arg);
}


x86 assembly (clang, -O0):
<l_setList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11aa <l_setList+0x8a>
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
lea    0xe95(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1197 <l_setList+0x77>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1174 <l_setList+0x54>
jmp    119c <l_setList+0x7c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <l_setList+0x25>
cmpl   $0x0,-0x28(%rbp)
jle    11c5 <l_setList+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <set_run_var@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_setList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %edi,%edi
jle    1198 <l_setList+0x78>
mov    %rcx,%r15
mov    %edi,%r12d
mov    %rdx,(%rsp)
add    $0x1,%r12d
mov    $0x1,%ebp
xor    %r14d,%r14d
mov    $0xfffffffe,%r13d
xchg   %ax,%ax
movslq %r14d,%r14
lea    (%rbx,%r14,1),%rdi
movsbl (%r15,%rbp,1),%edx
lea    0xe9d(%rip),%rsi
call   1040 <sprintf@plt>
lea    (%r14,%r13,1),%rax
add    $0xffffffffffffffff,%r14
add    $0x1,%rax
cmpb   $0x0,0x1(%rbx,%r14,1)
lea    0x1(%r14),%r14
jne    1170 <l_setList+0x50>
add    $0x1,%rbp
cmp    %r12,%rbp
jne    1150 <l_setList+0x30>
test   %r14d,%r14d
mov    (%rsp),%rdx
jle    1198 <l_setList+0x78>
mov    %eax,%eax
movb   $0x0,(%rbx,%rax,1)
mov    %rdx,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <set_run_var@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d,\00"
define void @l_setList(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %10
store i32 1, i32* %9
br label %11
11: ; preds = %38, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %24)
br label %26
26: ; preds = %34, %15
%27 = load i8*, i8** %6
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = load i32, i32* %10
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
br label %26
37: ; preds = %26
br label %38
38: ; preds = %37
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %11
41: ; preds = %11
%42 = load i32, i32* %10
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i8*, i8** %6
%46 = load i32, i32* %10
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
store i8 0, i8* %49
br label %50
50: ; preds = %44, %41
%51 = load i8*, i8** %7
%52 = load i8*, i8** %6
%53 = call i32 @set_run_var(i8* %51, i8* %52)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d,\00"
define void @l_setList(i32 %0, i8* %1, i8* %2, i8* nocapture %3) {
%5 = icmp slt i32 %0, 1
br i1 %5, label %34, label %6
6: ; preds = %4
%7 = add nuw i32 %0, 1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %24
%10 = phi i64 [ 1, %6 ], [ %25, %24 ]
%11 = phi i64 [ 0, %6 ], [ %19, %24 ]
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = getelementptr inbounds i8, i8* %3, i64 %10
%16 = load i8, i8* %15
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %16)
br label %18
18: ; preds = %18, %9
%19 = phi i64 [ %23, %18 ], [ %13, %9 ]
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
%23 = add i64 %19, 1
br i1 %22, label %24, label %18
24: ; preds = %18
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %9
27: ; preds = %24
%28 = trunc i64 %19 to i32
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = add i64 %19, 4294967295
%32 = and i64 %31, 4294967295
%33 = getelementptr inbounds i8, i8* %1, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %4, %30, %27
%35 = tail call i32 @set_run_var(i8* %2, i8* %1)
ret void
}