#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 */
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int arr[3] = {10, 20}, total = 0;
  arr[2] = 30;
  for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {
    total += arr[i];
    printf("arr[%d] = %d\n", i, arr[i]);
  }
  int b[2];
  for (int i = 0; i < sizeof(b) / sizeof(2); i++) {
    printf("\nEnter a integer: ");
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < sizeof(b) / sizeof(b[0]); i++) {
    total += b[i];
    printf("b[%d] = %d\n", i, b[i]);
  }
  printf("\nTotal: %d\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1e,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x3,%rax
jae    119b <main+0x7b>
movslq -0x18(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
movslq -0x18(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <main+0x38>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x2,%rax
jae    11e7 <main+0xc7>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a2 <main+0x82>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    $0x2,%rax
jae    1231 <main+0x111>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ee <main+0xce>
mov    -0x14(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1e,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea5(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%ebx
lea    0xe7c(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
add    %edx,%ebx
add    $0x3c,%ebx
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arr = [3 x i32] [i32 10, i32 20, i32 0]
@.str = [14 x i8] c"arr[%d] = %d\0A\00"
@.str.1 = [19 x i8] c"\0AEnter a integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"b[%d] = %d\0A\00"
@.str.4 = [12 x i8] c"\0ATotal: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [3 x i32]* %2 to i8*
store i32 0, i32* %3
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 30, i32* %9
store i32 0, i32* %4
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = icmp ult i64 %12, 3
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %4
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %25)
br label %27
27: ; preds = %14
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %10
30: ; preds = %10
store i32 0, i32* %6
br label %31
31: ; preds = %41, %30
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = icmp ult i64 %33, 2
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %38
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %31
44: ; preds = %31
store i32 0, i32* %7
br label %45
45: ; preds = %62, %44
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = icmp ult i64 %47, 2
br i1 %48, label %49, label %65
49: ; preds = %45
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, %53
store i32 %55, i32* %3
%56 = load i32, i32* %7
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %56, i32 %60)
br label %62
62: ; preds = %49
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %45
65: ; preds = %45
%66 = load i32, i32* %3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %66)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"arr[%d] = %d\0A\00"
@.str.1 = [19 x i8] c"\0AEnter a integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"b[%d] = %d\0A\00"
@.str.4 = [12 x i8] c"\0ATotal: %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32 10)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i32 20)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 2, i32 30)
%5 = bitcast [2 x i32]* %1 to i8*
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %7
%13 = add nsw i32 %12, 60
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %12)
%15 = load i32, i32* %10
%16 = add nsw i32 %15, %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %15)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret i32 0
}