#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 */
typedef struct TYPE_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct TYPE_6__ {
  int /*<<< orphan*/ tv_nsec;
};
struct TYPE_5__ {
  int /*<<< orphan*/ tv_nsec;
};
struct TYPE_4__ {
  int /*<<< orphan*/ tv_nsec;
};
struct stat {
  TYPE_3__ st_ctim;
  TYPE_2__ st_mtim;
  TYPE_1__ st_atim;
  int /*<<< orphan*/ st_ctime;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  time_t t;
  struct stat st;
  if (argc != 4) {
    fprintf(stderr, "Wrong argument num!\n");
    return 1;
  }
  if (stat(argv[1], &st) != 0) {
    perror("stat failed");
    return 1;
  }
  if (strcmp(argv[3], "sec") == 0) {
    if (strcmp(argv[2], "atime") == 0)
      t = st.st_atime;
    else if (strcmp(argv[2], "mtime") == 0)
      t = st.st_mtime;
    else
      t = st.st_ctime;
  } else if (strcmp(argv[3], "nsec") == 0) {
    if (strcmp(argv[2], "atime") == 0)
      t = st.st_atim.tv_nsec;
    else if (strcmp(argv[2], "mtime") == 0)
      t = st.st_mtim.tv_nsec;
    else
      t = st.st_ctim.tv_nsec;
  } else {
    fprintf(stderr, "Wrong argument: %s\n", argv[3]);
    return 1;
  }
  printf("%lu\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1193 <main+0x43>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130c <main+0x1bc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     11c6 <main+0x76>
lea    0xe60(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    130c <main+0x1bc>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe59(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1246 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    120d <main+0xbd>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1241 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1236 <main+0xe6>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    123c <main+0xec>
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1241 <main+0xf1>
jmp    12f6 <main+0x1a6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdd8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c6 <main+0x176>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdae(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    128d <main+0x13d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12c1 <main+0x171>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd8b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12b6 <main+0x166>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12bc <main+0x16c>
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12c1 <main+0x171>
jmp    12f1 <main+0x1a1>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130c <main+0x1bc>
jmp    12f6 <main+0x1a6>
mov    -0x14(%rbp),%esi
lea    0xd46(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x4,%edi
jne    11c3 <main+0x73>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    1256 <main+0x106>
mov    0x18(%rbx),%rdi
lea    0xeaf(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e4 <main+0x94>
mov    0x18(%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1214 <main+0xc4>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbx),%rdx
lea    0xe80(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    127b <main+0x12b>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    127b <main+0x12b>
mov    0x10(%rbx),%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1244 <main+0xf4>
mov    0x10(%rbx),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     124a <main+0xfa>
mov    0x14(%rsp),%esi
jmp    126d <main+0x11d>
mov    0x10(%rbx),%rdi
lea    0xe02(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1250 <main+0x100>
mov    0x10(%rbx),%rdi
lea    0xdf3(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1269 <main+0x119>
mov    0x8(%rsp),%esi
jmp    126d <main+0x11d>
mov    0x1c(%rsp),%esi
jmp    126d <main+0x11d>
mov    0x18(%rsp),%esi
jmp    126d <main+0x11d>
mov    0x10(%rsp),%esi
jmp    126d <main+0x11d>
lea    0xdb8(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    127b <main+0x12b>
mov    0xc(%rsp),%esi
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { %struct.TYPE_6__, %struct.TYPE_5__, %struct.TYPE_4__, i32, i32, i32 }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Wrong argument num!\0A\00"
@.str.1 = [12 x i8] c"stat failed\00"
@.str.2 = [4 x i8] c"sec\00"
@.str.3 = [6 x i8] c"atime\00"
@.str.4 = [6 x i8] c"mtime\00"
@.str.5 = [5 x i8] c"nsec\00"
@.str.6 = [20 x i8] c"Wrong argument: %s\0A\00"
@.str.7 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %92
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @stat(i8* %16, %struct.stat* %7)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %92
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %50
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 5
%35 = load i32, i32* %34
store i32 %35, i32* %6
br label %49
36: ; preds = %27
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 4
%44 = load i32, i32* %43
store i32 %44, i32* %6
br label %48
45: ; preds = %36
%46 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 3
%47 = load i32, i32* %46
store i32 %47, i32* %6
br label %48
48: ; preds = %45, %42
br label %49
49: ; preds = %48, %33
br label %89
50: ; preds = %21
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %82
56: ; preds = %50
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %56
%63 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%64 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %63, i32 0, i32 0
%65 = load i32, i32* %64
store i32 %65, i32* %6
br label %81
66: ; preds = %56
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %66
%73 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%74 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %73, i32 0, i32 0
%75 = load i32, i32* %74
store i32 %75, i32* %6
br label %80
76: ; preds = %66
%77 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %77, i32 0, i32 0
%79 = load i32, i32* %78
store i32 %79, i32* %6
br label %80
80: ; preds = %76, %72
br label %81
81: ; preds = %80, %62
br label %88
82: ; preds = %50
%83 = load i32, i32* @stderr
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 3
%86 = load i8*, i8** %85
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %86)
store i32 1, i32* %3
br label %92
88: ; preds = %81
br label %89
89: ; preds = %88, %49
%90 = load i32, i32* %6
%91 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %90)
store i32 0, i32* %3
br label %92
92: ; preds = %89, %82, %19, %10
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
%struct.stat = type { %struct.TYPE_6__, %struct.TYPE_5__, %struct.TYPE_4__, i32, i32, i32 }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Wrong argument num!\0A\00"
@.str.1 = [12 x i8] c"stat failed\00"
@.str.2 = [4 x i8] c"sec\00"
@.str.3 = [6 x i8] c"atime\00"
@.str.4 = [6 x i8] c"mtime\00"
@.str.5 = [5 x i8] c"nsec\00"
@.str.6 = [20 x i8] c"Wrong argument: %s\0A\00"
@.str.7 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i32 %0, 4
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %68
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @stat(i8* %11, %struct.stat* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %68
16: ; preds = %9
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %39
21: ; preds = %16
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 5
%28 = load i32, i32* %27
br label %65
29: ; preds = %21
%30 = load i8*, i8** %22
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 4
%35 = load i32, i32* %34
br label %65
36: ; preds = %29
%37 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
%38 = load i32, i32* %37
br label %65
39: ; preds = %16
%40 = load i8*, i8** %17
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %61
43: ; preds = %39
%44 = getelementptr inbounds i8*, i8** %1, i64 2
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2, i32 0
%50 = load i32, i32* %49
br label %65
51: ; preds = %43
%52 = load i8*, i8** %44
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1, i32 0
%57 = load i32, i32* %56
br label %65
58: ; preds = %51
%59 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0, i32 0
%60 = load i32, i32* %59
br label %65
61: ; preds = %39
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %17
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %63)
br label %68
65: ; preds = %55, %58, %48, %26, %36, %33
%66 = phi i32 [ %28, %26 ], [ %35, %33 ], [ %38, %36 ], [ %50, %48 ], [ %57, %55 ], [ %60, %58 ]
%67 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %61, %14, %6
%69 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 0, %65 ], [ 1, %61 ]
ret i32 %69
}