#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sc_mount_opt2str(char *, int, unsigned long);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("usage: decode-mount-opts OPT\n");
    return 0;
  }
  char *end;
  unsigned long mountflags = strtoul(argv[1], &end, 0);
  if (*end != '\0') {
    fprintf(stderr, "cannot parse given argument as a number\n");
    return 1;
  }
  char buf[1000] = {0};
  printf("%#lx is %s\n", mountflags,
         sc_mount_opt2str(buf, sizeof buf, mountflags));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x3d>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1226 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d5 <main+0x85>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1226 <main+0xd6>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3e8,%esi
call   1030 <sc_mount_opt2str@plt>
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x2,%edi
jne    11ac <main+0x4c>
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %rax,%r14
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     11bc <main+0x5c>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    11f3 <main+0x93>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    11f3 <main+0x93>
lea    0x10(%rsp),%r15
mov    $0x3e8,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1040 <sc_mount_opt2str@plt>
lea    0xe42(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"usage: decode-mount-opts OPT\0A\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"cannot parse given argument as a number\0A\00"
@.str.2 = [12 x i8] c"%#lx is %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %32
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strtoul(i8* %16, i8** %6, i32 0)
store i64 %17, i64* %7
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %32
25: ; preds = %13
%26 = bitcast [1000 x i8]* %8 to i8*
%27 = load i64, i64* %7
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%29 = load i64, i64* %7
%30 = call i32 @sc_mount_opt2str(i8* %28, i32 1000, i64 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %27, i32 %30)
store i32 0, i32* %3
br label %32
32: ; preds = %25, %22, %11
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [41 x i8] c"cannot parse given argument as a number\0A\00"
@.str.2 = [12 x i8] c"%#lx is %s\0A\00"
@str = [29 x i8] c"usage: decode-mount-opts OPT\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [1000 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %25
8: ; preds = %2
%9 = bitcast i8** %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strtoul(i8* %11, i8** %3, i32 0)
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %23
19: ; preds = %8
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%21 = call i32 @sc_mount_opt2str(i8* %20, i32 1000, i64 %12)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %12, i32 %21)
br label %23
23: ; preds = %19, %16
%24 = phi i32 [ 1, %16 ], [ 0, %19 ]
br label %25
25: ; preds = %23, %6
%26 = phi i32 [ 0, %6 ], [ %24, %23 ]
ret i32 %26
}