#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strdup(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char *data;
  char *temp;
  int array[100];
  int i, n;
  if (argc < 2) {
    printf("Usage:<prog_name> <comma seperated list of numbers>\n");
    return 1;
  }
  data = strdup(argv[1]);
  temp = strtok(data, ",");
  array[0] = atoi(temp);
  i = 1;
  while (temp) {
    temp = strtok(NULL, ",");
    if (temp) {
      array[i++] = atoi(temp);
    }
  }
  n = i - 1;
  for (i = 0; i <= n; i++) {
    printf("value = %d\n", array[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117d <main+0x3d>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <main+0x131>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1b0(%rbp)
movl   $0x1,-0x1b4(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     120f <main+0xcf>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe64(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     120a <main+0xca>
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x1b4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1b4(%rbp)
cltq
mov    %ecx,-0x1b0(%rbp,%rax,4)
jmp    11bb <main+0x7b>
mov    -0x1b4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
movl   $0x0,-0x1b4(%rbp)
mov    -0x1b4(%rbp),%eax
cmp    -0x1b8(%rbp),%eax
jg     126a <main+0x12a>
movslq -0x1b4(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    1228 <main+0xe8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x198,%rsp
cmp    $0x1,%edi
jg     117a <main+0x2a>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    1216 <main+0xc6>
mov    0x8(%rsi),%rdi
call   1070 <strdup@plt>
lea    0xe76(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,(%rsp)
mov    $0x1,%r12d
test   %r14,%r14
je     11ef <main+0x9f>
lea    0xe4e(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     11ef <main+0x9f>
mov    $0x1,%r12d
lea    0xe35(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,(%rsp,%r12,4)
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
add    $0x1,%r12
test   %rax,%rax
jne    11d0 <main+0x80>
xor    %r14d,%r14d
lea    0xe09(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1200 <main+0xb0>
mov    %r14d,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Usage:<prog_name> <comma seperated list of numbers>\0A\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [12 x i8] c"value = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [100 x i32]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %57
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = call i32 @atoi(i8* %22)
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 0
store i32 %23, i32* %24
store i32 1, i32* %9
br label %25
25: ; preds = %39, %15
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %7
%30 = load i8*, i8** %7
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = load i8*, i8** %7
%34 = call i32 @atoi(i8* %33)
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %32, %28
br label %25
40: ; preds = %25
%41 = load i32, i32* %9
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %10
store i32 0, i32* %9
br label %43
43: ; preds = %53, %40
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = icmp sle i32 %44, %45
br i1 %46, label %47, label %56
47: ; preds = %43
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %47
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %43
56: ; preds = %43
store i32 0, i32* %3
br label %57
57: ; preds = %56, %13
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c",\00"
@.str.2 = [12 x i8] c"value = %d\0A\00"
@str = [52 x i8] c"Usage:<prog_name> <comma seperated list of numbers>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
br label %39
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @strdup(i8* %10)
%12 = tail call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
store i32 %13, i32* %14
%15 = icmp eq i8* %12, null
br i1 %15, label %21, label %16
16: ; preds = %8
%17 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %21, label %23
19: ; preds = %23
%20 = zext i32 %27 to i64
br label %21
21: ; preds = %19, %16, %8
%22 = phi i64 [ 1, %8 ], [ 1, %16 ], [ %20, %19 ]
br label %32
23: ; preds = %16, %23
%24 = phi i8* [ %30, %23 ], [ %17, %16 ]
%25 = phi i32 [ %27, %23 ], [ 1, %16 ]
%26 = tail call i32 @atoi(i8* %24)
%27 = add nuw nsw i32 %25, 1
%28 = zext i32 %25 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %28
store i32 %26, i32* %29
%30 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %19, label %23
32: ; preds = %21, %32
%33 = phi i64 [ 0, %21 ], [ %37, %32 ]
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %33, 1
%38 = icmp eq i64 %37, %22
br i1 %38, label %39, label %32
39: ; preds = %32, %6
%40 = phi i32 [ 1, %6 ], [ 0, %32 ]
ret i32 %40
}