#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *args[]) {
  if (argc < 2) {
    fprintf(stderr, "useage error: %s\n", strerror(errno));
    printf("useage:%s <pathname>\n", args[0]);
    exit(1);
  }
  struct stat st;
  if (lstat(args[1], &st) < 0) {
    fprintf(stderr, "stat error: %s\n", strerror(errno));
    exit(1);
  }
  printf("%s size is %ld bytes\n", args[1], st.st_size);
  return 0;
}


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)
jge    11bb <main+0x6b>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <lstat@plt>
cmp    $0x0,%rax
jge    120c <main+0xbc>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe2b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    118a <main+0x3a>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1040 <lstat@plt>
test   %rax,%rax
js     11cd <main+0x7d>
mov    0x8(%rbx),%rsi
mov    (%rsp),%edx
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e4f(%rip),%rax
mov    (%rax),%ebp
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe58(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    (%rbx),%rsi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%ebx
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe3d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"useage error: %s\0A\00"
@errno = global i32 0
@.str.1 = [22 x i8] c"useage:%s <pathname>\0A\00"
@.str.2 = [16 x i8] c"stat error: %s\0A\00"
@.str.3 = [22 x i8] c"%s size is %ld bytes\0A\00"
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 slt i32 %7, 2
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @lstat(i8* %22, %struct.stat* %6)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %34, i32 %36)
ret i32 0
}

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