#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 */
unsigned int MS_RDONLY;
unsigned int MS_REMOUNT;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *getdev(char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ remount(char *, unsigned int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *dev;
  unsigned int flags;
  if (argc != 3) {
    fprintf(stderr, "%s: remount device [ro][rw]\n", argv[0]);
    return 1;
  }
  dev = getdev(argv[1]);
  if (!dev)
    dev = argv[1];
  if (strcmp(argv[2], "ro") == 0)
    flags = MS_RDONLY | MS_REMOUNT;
  else if (strcmp(argv[2], "rw") == 0)
    flags = MS_REMOUNT;
  else {
    fprintf(stderr, "%s: ro or rw required.\n", argv[0]);
    return 1;
  }
  if (remount(dev, flags)) {
    perror("umount");
    return 1;
  }
  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   $0x3,-0x8(%rbp)
je     1198 <main+0x48>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1289 <main+0x139>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getdev@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c0 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xa8>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
mov    0x2de2(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
jmp    1254 <main+0x104>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe19(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1227 <main+0xd7>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    124f <main+0xff>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde5(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1289 <main+0x139>
jmp    1254 <main+0x104>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <remount@plt>
cmp    $0x0,%rax
je     1282 <main+0x132>
lea    0xdca(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1289 <main+0x139>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11b0 <main+0x60>
mov    0x8(%rbx),%rdi
call   1040 <getdev@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1171 <main+0x21>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
lea    0xea1(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11cf <main+0x7f>
mov    0x10(%rbx),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e3 <main+0x93>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe75(%rip),%rsi
jmp    11c3 <main+0x73>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    11fe <main+0xae>
mov    0x2e12(%rip),%rax
mov    0x2df3(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
jmp    11ec <main+0x9c>
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1030 <remount@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1206 <main+0xb6>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe2e(%rip),%rdi
call   1070 <perror@plt>
jmp    11c8 <main+0x78>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"%s: remount device [ro][rw]\0A\00"
@.str.1 = [3 x i8] c"ro\00"
@MS_RDONLY = global i32 0
@MS_REMOUNT = global i32 0
@.str.2 = [3 x i8] c"rw\00"
@.str.3 = [24 x i8] c"%s: ro or rw required.\0A\00"
@.str.4 = [7 x i8] c"umount\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
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, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %60
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @getdev(i8* %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %27, label %23
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
br label %27
27: ; preds = %23, %16
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = load i32, i32* @MS_RDONLY
%35 = load i32, i32* @MS_REMOUNT
%36 = or i32 %34, %35
store i32 %36, i32* %7
br label %52
37: ; preds = %27
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = load i32, i32* @MS_REMOUNT
store i32 %44, i32* %7
br label %51
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %49)
store i32 1, i32* %3
br label %60
51: ; preds = %43
br label %52
52: ; preds = %51, %33
%53 = load i8*, i8** %6
%54 = load i32, i32* %7
%55 = call i64 @remount(i8* %53, i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %60
59: ; preds = %52
store i32 0, i32* %3
br label %60
60: ; preds = %59, %57, %45, %10
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"%s: remount device [ro][rw]\0A\00"
@.str.1 = [3 x i8] c"ro\00"
@MS_RDONLY = global i32 0
@MS_REMOUNT = global i32 0
@.str.2 = [3 x i8] c"rw\00"
@.str.3 = [24 x i8] c"%s: ro or rw required.\0A\00"
@.str.4 = [7 x i8] c"umount\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %41
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @getdev(i8* %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i8*, i8** %9
br label %15
15: ; preds = %13, %8
%16 = phi i8* [ %11, %8 ], [ %14, %13 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @MS_RDONLY
%23 = load i32, i32* @MS_REMOUNT
%24 = or i32 %23, %22
br label %35
25: ; preds = %15
%26 = load i8*, i8** %17
%27 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32, i32* @MS_REMOUNT
br label %35
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %1
%34 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %41
35: ; preds = %29, %21
%36 = phi i32 [ %24, %21 ], [ %30, %29 ]
%37 = tail call i64 @remount(i8* %16, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %35, %39, %31, %4
%42 = phi i32 [ 1, %4 ], [ 1, %39 ], [ 1, %31 ], [ 0, %35 ]
ret i32 %42
}