#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*/ clr();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ hello();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char *names[5] = {"Olga", "Peter", "Barbara", "John", "Dave"};
  void *p;
  int x[4] = {1, 2, 3, 4};
  int a = 4;
  p = &a;
  clr();
  for (int i = 1; i < 5; i = i + 2) {
    printf("Value of names [%d] = %s\n", i, names[i]);
  }
  for (int j = 0; j < 4; j++) {
    printf("Printing elements of the array: %d: x[%d]\n", j, x[j]);
  }
  printf("Printing p: %d", *(int *)p);
  printf("\nPrints output of function hello()");
  hello();
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe84(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe7f(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe76(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xef3(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xef0(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x4,-0x54(%rbp)
lea    -0x54(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <clr@plt>
movl   $0x1,-0x58(%rbp)
cmpl   $0x5,-0x58(%rbp)
jge    120b <main+0xbb>
mov    -0x58(%rbp),%esi
movslq -0x58(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x58(%rbp)
jmp    11d9 <main+0x89>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1243 <main+0xf3>
mov    -0x5c(%rbp),%esi
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1212 <main+0xc2>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <hello@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clr@plt>
lea    0xebc(%rip),%rbx
lea    0xeaa(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <hello@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Olga\00"
@.str.1 = [6 x i8] c"Peter\00"
@.str.2 = [8 x i8] c"Barbara\00"
@.str.3 = [5 x i8] c"John\00"
@.str.4 = [5 x i8] c"Dave\00"
@__const.main.x = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str.5 = [26 x i8] c"Value of names [%d] = %s\0A\00"
@.str.6 = [43 x i8] c"Printing elements of the array: %d: x[%d]\0A\00"
@.str.7 = [15 x i8] c"Printing p: %d\00"
@.str.8 = [35 x i8] c"\0APrints output of function hello()\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8*]
%3 = alloca i8*
%4 = alloca [4 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [5 x i8*]* %2 to i8*
%9 = bitcast i8* %8 to [5 x i8*]*
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8** %14
%15 = bitcast [4 x i32]* %4 to i8*
store i32 4, i32* %5
%16 = bitcast i32* %5 to i8*
store i8* %16, i8** %3
%17 = call i32 (...) @clr()
store i32 1, i32* %6
br label %18
18: ; preds = %28, %0
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i32, i32* %6
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %22, i8* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 2
store i32 %30, i32* %6
br label %18
31: ; preds = %18
store i32 0, i32* %7
br label %32
32: ; preds = %42, %31
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 4
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i32, i32* %7
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %36, i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %32
45: ; preds = %32
%46 = load i8*, i8** %3
%47 = bitcast i8* %46 to i32*
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 (...) @hello()
%52 = call i32 (...) @getchar()
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"Peter\00"
@.str.3 = [5 x i8] c"John\00"
@.str.5 = [26 x i8] c"Value of names [%d] = %s\0A\00"
@.str.6 = [43 x i8] c"Printing elements of the array: %d: x[%d]\0A\00"
@.str.7 = [15 x i8] c"Printing p: %d\00"
@.str.8 = [35 x i8] c"\0APrints output of function hello()\00"
define i32 @main() {
%1 = tail call i32 (...) @clr()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 1)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 2)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 3)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 4)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%10 = tail call i32 (...) @hello()
%11 = tail call i32 (...) @getchar()
ret i32 0
}