#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 */
struct stat {
  int st_size;
  int st_ino;
  int st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stmode_handler(int);
void buf_handler(const struct stat *buf) {
  printf("file_size: %lld\n", buf->st_size);
  printf("inode:%llu\n", buf->st_ino);
  printf("st_mode:%x\n", buf->st_mode);
  stmode_handler(buf->st_mode);
}


x86 assembly (clang, -O0):
<buf_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
call   1040 <stmode_handler@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buf_handler>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%esi
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%edi
pop    %rbx
jmp    1040 <stmode_handler@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@.str = [17 x i8] c"file_size: %lld\0A\00"
@.str.1 = [12 x i8] c"inode:%llu\0A\00"
@.str.2 = [12 x i8] c"st_mode:%x\0A\00"
define void @buf_handler(%struct.stat* %0) {
%2 = alloca %struct.stat*
store %struct.stat* %0, %struct.stat** %2
%3 = load %struct.stat*, %struct.stat** %2
%4 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%5 = load i32, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load %struct.stat*, %struct.stat** %2
%8 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load %struct.stat*, %struct.stat** %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 2
%13 = load i32, i32* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load %struct.stat*, %struct.stat** %2
%16 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 @stmode_handler(i32 %17)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@.str = [17 x i8] c"file_size: %lld\0A\00"
@.str.1 = [12 x i8] c"inode:%llu\0A\00"
@.str.2 = [12 x i8] c"st_mode:%x\0A\00"
define void @buf_handler(%struct.stat* nocapture %0) {
%2 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 2
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %8
%12 = tail call i32 @stmode_handler(i32 %11)
ret void
}