#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 /*<<< orphan*/ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct stat infobuf;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (stat(argv[1], &infobuf) == -1) {
    fprintf(stderr, "Err. stat(): %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  } else
    printf("The size of %s is %ld K\n", argv[1], infobuf.st_size);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    11ee <main+0x9e>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe3b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1193 <main+0x43>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     11a8 <main+0x58>
mov    0x8(%rbx),%rsi
mov    0x8(%rsp),%edx
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe5a(%rip),%rsi
jmp    11cb <main+0x7b>
mov    0x2e31(%rip),%rax
mov    (%rax),%ebx
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe50(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"Err. stat(): %s\0A\00"
@errno = global i32 0
@.str.2 = [25 x i8] c"The size of %s is %ld K\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @stat(i8* %20, %struct.stat* %6)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %17
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %33, i32 %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"Err. stat(): %s\0A\00"
@errno = global i32 0
@.str.2 = [25 x i8] c"The size of %s is %ld K\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @stat(i8* %14, %struct.stat* %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %12
%25 = load i8*, i8** %13
%26 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%27 = load i32, i32* %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %25, i32 %27)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}