#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 array_size;
int average(int *, int);
int /*<<< orphan*/ func(int *);
int /*<<< orphan*/ ln(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(char *, char *);
int /*<<< orphan*/ write(char *, char *, char *);
int main(void) {
  ln("hello, world");
  int *p, i, value = 10, ave, array[] = {1, 4, 2, 4, 4}, buf;
  const array_size = sizeof array / sizeof(int);
  p = &i;
  *p = 10;
  printf("p = %p\n", p);
  printf("*p = %p\n", *p);
  printf("i = %p\n", i);
  printf("&i = %p\n", &i);
  printf("&value = %p\n", &value);
  func(&value);
  printf("value = %d\n", value);
  ave = average(array, array_size);
  ave = average(NULL, array_size);
  printf("%d\n", ave);
  write("text.txt", "w", "hewwo, world");
  buf = read("text.txt", "rb");
  printf("%d\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1080 <ln@plt>
movl   $0xa,-0x18(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed2(%rip),%eax
mov    %eax,-0x20(%rbp)
movl   $0x5,-0x38(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xa,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe15(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1070 <func@plt>
mov    -0x18(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1060 <average@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x5,%esi
call   1060 <average@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdcf(%rip),%rdi
lea    0xdd1(%rip),%rsi
lea    0xdcc(%rip),%rdx
call   1030 <write@plt>
lea    0xdb5(%rip),%rdi
lea    0xdc6(%rip),%rsi
call   1050 <read@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xe92(%rip),%rdi
call   1080 <ln@plt>
movl   $0xa,0xc(%rsp)
mov    0xeef(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0xa,0x8(%rsp)
lea    0xe6e(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe34(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <func@plt>
mov    0xc(%rsp),%esi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
call   1060 <average@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1060 <average@plt>
lea    0xdfe(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdef(%rip),%rbx
lea    0xdf1(%rip),%rsi
lea    0xdec(%rip),%rdx
mov    %rbx,%rdi
call   1030 <write@plt>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
call   1050 <read@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"hello, world\00"
@__const.main.array = [5 x i32] [i32 1, i32 4, i32 2, i32 4, i32 4]
@.str.1 = [8 x i8] c"p = %p\0A\00"
@.str.2 = [9 x i8] c"*p = %p\0A\00"
@.str.3 = [8 x i8] c"i = %p\0A\00"
@.str.4 = [9 x i8] c"&i = %p\0A\00"
@.str.5 = [13 x i8] c"&value = %p\0A\00"
@.str.6 = [12 x i8] c"value = %d\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.8 = [9 x i8] c"text.txt\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [13 x i8] c"hewwo, world\00"
@.str.11 = [3 x i8] c"rb\00"
@array_size = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [5 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @ln(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 10, i32* %4
%10 = bitcast [5 x i32]* %6 to i8*
store i32 5, i32* %8
store i32* %3, i32** %2
%11 = load i32*, i32** %2
store i32 10, i32* %11
%12 = load i32*, i32** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%21 = call i32 @func(i32* %4)
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%25 = call i32 @average(i32* %24, i32 5)
store i32 %25, i32* %5
%26 = call i32 @average(i32* null, i32 5)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = call i32 @write(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%30 = call i32 @read(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"hello, world\00"
@__const.main.array = [5 x i32] [i32 1, i32 4, i32 2, i32 4, i32 4]
@.str.1 = [8 x i8] c"p = %p\0A\00"
@.str.2 = [9 x i8] c"*p = %p\0A\00"
@.str.3 = [8 x i8] c"i = %p\0A\00"
@.str.4 = [9 x i8] c"&i = %p\0A\00"
@.str.5 = [13 x i8] c"&value = %p\0A\00"
@.str.6 = [12 x i8] c"value = %d\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.8 = [9 x i8] c"text.txt\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [13 x i8] c"hewwo, world\00"
@.str.11 = [3 x i8] c"rb\00"
@array_size = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = tail call i32 @ln(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
store i32 10, i32* %2
%7 = bitcast [5 x i32]* %3 to i8*
store i32 10, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%15 = call i32 @func(i32* %2)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%19 = call i32 @average(i32* %18, i32 5)
%20 = call i32 @average(i32* null, i32 5)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %20)
%22 = call i32 @write(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%23 = call i32 @read(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %23)
ret i32 0
}