#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 getRandomNumber(int);
scalar_t__ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int i, sum = 0, x[10];
  for (i = 0; i < 10; i++) {
    x[i] = getRandomNumber(1000);
  }
  printf("%s\t%s\n", "Value", "Total characters");
  for (i = 0; i < 10; i++) {
    sum += printf("%d", x[i]);
    printf("\t%d\n", sum);
    x[i] = getRandomNumber(1000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1199 <main+0x59>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x2d>
lea    0xe60(%rip),%rdi
lea    0xe60(%rip),%rsi
lea    0xe5f(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    121c <main+0xdc>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bc <main+0x7c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%ebx
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%r13d
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%r12d
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,%r14d
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,(%rsp)
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,0x4(%rsp)
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,0x8(%rsp)
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,0xc(%rsp)
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,0x10(%rsp)
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %eax,0x14(%rsp)
lea    0xe17(%rip),%rdi
lea    0xe17(%rip),%rsi
lea    0xe16(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe19(%rip),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rax,%rbx
lea    0xe06(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <getRandomNumber@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s\09%s\0A\00"
@.str.1 = [6 x i8] c"Value\00"
@.str.2 = [17 x i8] c"Total characters\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
store i32 0, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = call i32 @getRandomNumber(i32 1000)
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %13
store i32 %11, i32* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %7
18: ; preds = %7
%19 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %20
20: ; preds = %39, %18
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %42
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i32 @getRandomNumber(i32 1000)
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %23
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %20
42: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s\09%s\0A\00"
@.str.1 = [6 x i8] c"Value\00"
@.str.2 = [17 x i8] c"Total characters\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"\09%d\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @getRandomNumber(i32 1000)
%4 = tail call i32 @getRandomNumber(i32 1000)
%5 = tail call i32 @getRandomNumber(i32 1000)
%6 = tail call i32 @getRandomNumber(i32 1000)
%7 = tail call i32 @getRandomNumber(i32 1000)
%8 = tail call i32 @getRandomNumber(i32 1000)
%9 = tail call i32 @getRandomNumber(i32 1000)
%10 = tail call i32 @getRandomNumber(i32 1000)
%11 = tail call i32 @getRandomNumber(i32 1000)
%12 = tail call i32 @getRandomNumber(i32 1000)
%13 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %3)
%15 = trunc i64 %14 to i32
%16 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = tail call i32 @getRandomNumber(i32 1000)
%18 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%19 = shl i64 %14, 32
%20 = ashr exact i64 %19, 32
%21 = add nsw i64 %18, %20
%22 = trunc i64 %21 to i32
%23 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = tail call i32 @getRandomNumber(i32 1000)
%25 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%26 = shl i64 %21, 32
%27 = ashr exact i64 %26, 32
%28 = add nsw i64 %25, %27
%29 = trunc i64 %28 to i32
%30 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = tail call i32 @getRandomNumber(i32 1000)
%32 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%33 = shl i64 %28, 32
%34 = ashr exact i64 %33, 32
%35 = add nsw i64 %32, %34
%36 = trunc i64 %35 to i32
%37 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = tail call i32 @getRandomNumber(i32 1000)
%39 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%40 = shl i64 %35, 32
%41 = ashr exact i64 %40, 32
%42 = add nsw i64 %39, %41
%43 = trunc i64 %42 to i32
%44 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = tail call i32 @getRandomNumber(i32 1000)
%46 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%47 = shl i64 %42, 32
%48 = ashr exact i64 %47, 32
%49 = add nsw i64 %46, %48
%50 = trunc i64 %49 to i32
%51 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = tail call i32 @getRandomNumber(i32 1000)
%53 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%54 = shl i64 %49, 32
%55 = ashr exact i64 %54, 32
%56 = add nsw i64 %53, %55
%57 = trunc i64 %56 to i32
%58 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = tail call i32 @getRandomNumber(i32 1000)
%60 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%61 = shl i64 %56, 32
%62 = ashr exact i64 %61, 32
%63 = add nsw i64 %60, %62
%64 = trunc i64 %63 to i32
%65 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %64)
%66 = tail call i32 @getRandomNumber(i32 1000)
%67 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%68 = shl i64 %63, 32
%69 = ashr exact i64 %68, 32
%70 = add nsw i64 %67, %69
%71 = trunc i64 %70 to i32
%72 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %71)
%73 = tail call i32 @getRandomNumber(i32 1000)
%74 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%75 = add i64 %74, %70
%76 = trunc i64 %75 to i32
%77 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %76)
%78 = tail call i32 @getRandomNumber(i32 1000)
ret i32 0
}