#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*/ clock();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char const *, char *, int *);
int main(int argc, const char *argv[]) {
  if (argc < 2) {
    printf("Usage: datagen <num-elements>\n");
    return 1;
  }
  int num;
  sscanf(argv[1], "%d", &num);
  srand(clock());
  printf("{");
  for (int a = 0; a < (num - 1); a++) {
    int r = rand();
    printf("%i,", r);
  }
  int r = rand();
  printf("%i}\n", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118a <main+0x3a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1221 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe86(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ff <main+0xaf>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c5 <main+0x75>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1194 <main+0x24>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    1218 <main+0xa8>
mov    0x8(%rsi),%rdi
lea    0xe61(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmpl   $0x2,0xc(%rsp)
jl     1201 <main+0x91>
lea    0xe31(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebp
jl     11e0 <main+0x70>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xdf8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: datagen <num-elements>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"{\00"
@.str.3 = [4 x i8] c"%i,\00"
@.str.4 = [5 x i8] c"%i}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %38
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%19 = call i32 (...) @clock()
%20 = call i32 @srand(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %22
22: ; preds = %31, %14
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = call i32 (...) @rand()
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %22
34: ; preds = %22
%35 = call i32 (...) @rand()
store i32 %35, i32* %9
%36 = load i32, i32* %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %36)
store i32 0, i32* %3
br label %38
38: ; preds = %34, %12
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%i,\00"
@.str.4 = [5 x i8] c"%i}\0A\00"
@str = [30 x i8] c"Usage: datagen <num-elements>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %28
7: ; preds = %2
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = call i32 (...) @clock()
%13 = call i32 @srand(i32 %12)
%14 = call i32 @putchar(i32 123)
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %20, %7
%18 = call i32 (...) @rand()
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %28
20: ; preds = %7, %20
%21 = phi i32 [ %24, %20 ], [ 0, %7 ]
%22 = call i32 (...) @rand()
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %21, 1
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
%27 = icmp slt i32 %24, %26
br i1 %27, label %20, label %17
28: ; preds = %17, %5
%29 = phi i32 [ 1, %5 ], [ 0, %17 ]
ret i32 %29
}