#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*/ printf(char *);
int main(int argc, char *argv[]) {
  int determine_command(char *);
  void format_output(int, char *);
  int choice = -1;
  char *argv2 = "";
  switch (argc) {
  case 1:
    printf("Gmem_test: you must specify either read or write\nPlease type "
           "gmem_test -help for further details\n");
    return 0;
  case 2:
  case 3:
    choice = determine_command(argv[1]);
    if (argc > 2)
      argv2 = argv[2];
    format_output(choice, argv2);
    return 0;
  default:
    printf("Gmem_test: too many arguments\nPlease type gmem_test -help for "
           "usage information\n");
    return 0;
  }
  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)
movl   $0xffffffff,-0x14(%rbp)
lea    0xf5e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     1180 <main+0x50>
jmp    116c <main+0x3c>
mov    -0x24(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1198 <main+0x68>
jmp    11d6 <main+0xa6>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <determine_command@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11be <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <format_output@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <main+0xb9>
lea    0xe85(%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   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0x2(%rbx),%eax
cmp    $0x2,%eax
jae    1155 <main+0x25>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <determine_command@plt>
cmp    $0x3,%ebx
jb     1163 <main+0x33>
mov    0x10(%r14),%rsi
jmp    116a <main+0x3a>
cmp    $0x1,%ebx
jne    1173 <main+0x43>
lea    0xe9f(%rip),%rdi
jmp    117a <main+0x4a>
lea    0xf46(%rip),%rsi
mov    %eax,%edi
call   1040 <format_output@plt>
jmp    117f <main+0x4f>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [98 x i8] c"Gmem_test: you must specify either read or write\0APlease type gmem_test -help for further details\0A\00"
@.str.2 = [81 x i8] c"Gmem_test: too many arguments\0APlease type gmem_test -help for usage information\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i32, i32* %4
switch i32 %8, label %25 [
i32 1, label %9
i32 2, label %11
i32 3, label %11
]
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %27
11: ; preds = %2, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @determine_command(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %7
br label %22
22: ; preds = %18, %11
%23 = load i32, i32* %6
%24 = load i8*, i8** %7
store i32 0, i32* %3
br label %27
25: ; preds = %2
%26 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %27
27: ; preds = %25, %22, %9
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@str = [97 x i8] c"Gmem_test: you must specify either read or write\0APlease type gmem_test -help for further details\00"
@str.3 = [80 x i8] c"Gmem_test: too many arguments\0APlease type gmem_test -help for usage information\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %15 [
i32 1, label %3
i32 2, label %5
i32 3, label %5
]
3: ; preds = %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @str, i64 0, i64 0))
br label %17
5: ; preds = %2, %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @determine_command(i8* %7)
%9 = icmp ugt i32 %0, 2
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
br label %13
13: ; preds = %10, %5
%14 = phi i8* [ %12, %10 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %5 ]
tail call void @format_output(i32 %8, i8* %14)
br label %17
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %3
ret i32 0
}