#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*/ help(char *);
int /*<<< orphan*/ patch(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int no_options = 0;
  for (int i = 1; i < argc; ++i) {
    if (argv[i][0] != '-' || no_options)
      patch(argv[i]);
    else if (strcmp(argv[i], "--help") == 0)
      help(argv[0]);
    else if (strcmp(argv[i], "--") == 0)
      no_options = 1;
    else {
      fprintf(stderr, "Unknown commandline option\n");
      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)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1247 <main+0x107>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1192 <main+0x52>
cmpl   $0x0,-0x14(%rbp)
je     11a8 <main+0x68>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <patch@plt>
jmp    1234 <main+0xf4>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11db <main+0x9b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <help@plt>
jmp    122f <main+0xef>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1209 <main+0xc9>
movl   $0x1,-0x14(%rbp)
jmp    122a <main+0xea>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0x10e>
jmp    122f <main+0xef>
jmp    1234 <main+0xf4>
jmp    1239 <main+0xf9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <main+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
jl     11ed <main+0xad>
mov    %rsi,%r13
mov    %edi,%r12d
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe96(%rip),%r14
lea    0xe96(%rip),%r15
jmp    118e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1060 <patch@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     11cf <main+0x8f>
mov    0x0(%r13,%rbx,8),%rdi
cmpb   $0x2d,(%rdi)
jne    1180 <main+0x40>
test   %ebp,%ebp
jne    1180 <main+0x40>
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <main+0x82>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1185 <main+0x45>
jmp    11d3 <main+0x93>
mov    0x0(%r13),%rdi
call   1050 <help@plt>
xor    %ebp,%ebp
jmp    1185 <main+0x45>
xor    %eax,%eax
jmp    11ed <main+0xad>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"--\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"Unknown commandline option\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %8
8: ; preds = %60, %2
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %63
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 45
br i1 %21, label %25, label %22
22: ; preds = %12
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %22, %12
%26 = load i8**, i8*** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @patch(i8* %30)
br label %59
32: ; preds = %22
%33 = load i8**, i8*** %5
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %32
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @help(i8* %43)
br label %58
45: ; preds = %32
%46 = load i8**, i8*** %5
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %45
store i32 1, i32* %6
br label %57
54: ; preds = %45
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %64
57: ; preds = %53
br label %58
58: ; preds = %57, %40
br label %59
59: ; preds = %58, %25
br label %60
60: ; preds = %59
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %8
63: ; preds = %8
store i32 0, i32* %3
br label %64
64: ; preds = %63, %54
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"--\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"Unknown commandline option\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %34
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %30
%7 = phi i64 [ 1, %4 ], [ %32, %30 ]
%8 = phi i32 [ 0, %4 ], [ %31, %30 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 45
%13 = icmp ne i32 %8, 0
%14 = select i1 %12, i1 true, i1 %13
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = tail call i32 @patch(i8* %10)
br label %30
17: ; preds = %6
%18 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %1
%22 = tail call i32 @help(i8* %21)
br label %30
23: ; preds = %17
%24 = load i8*, i8** %9
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %34
30: ; preds = %23, %15, %20
%31 = phi i32 [ %8, %15 ], [ 0, %20 ], [ 1, %23 ]
%32 = add nuw nsw i64 %7, 1
%33 = icmp eq i64 %32, %5
br i1 %33, label %34, label %6
34: ; preds = %30, %2, %27
%35 = phi i32 [ 1, %27 ], [ 0, %2 ], [ 0, %30 ]
ret i32 %35
}