#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 */
scalar_t__ equal(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int parse_args(int argc, char **argv) {
  int i;
  for (i = 1; i < argc; i++) {
    if (equal(argv[i], "--long")) {
      fprintf(stderr, "Found --long .... take some action\n");
    } else if (equal(argv[i], "--short")) {
      fprintf(stderr, "Found --short .... take some action\n");
    } else {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11de <parse_args+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xeab(%rip),%rsi
call   1040 <equal@plt>
cmp    $0x0,%rax
je     117e <parse_args+0x5e>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11cb <parse_args+0xab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <equal@plt>
cmp    $0x0,%rax
je     11ba <parse_args+0x9a>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11c6 <parse_args+0xa6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <parse_args+0xc5>
jmp    11cb <parse_args+0xab>
jmp    11d0 <parse_args+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <parse_args+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
jl     11aa <parse_args+0x8a>
mov    %rsi,%rbx
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xebc(%rip),%r12
lea    0xebc(%rip),%r14
mov    0x2e8e(%rip),%r15
jmp    1171 <parse_args+0x51>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
call   1030 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11a8 <parse_args+0x88>
mov    (%rbx,%rbp,8),%rdi
mov    %r12,%rsi
call   1040 <equal@plt>
mov    %r14,%rsi
test   %rax,%rax
jne    1160 <parse_args+0x40>
mov    (%rbx,%rbp,8),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <equal@plt>
lea    0xe97(%rip),%rsi
test   %rax,%rax
jne    1160 <parse_args+0x40>
mov    $0xffffffff,%eax
jmp    11aa <parse_args+0x8a>
xor    %eax,%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"--long\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"Found --long .... take some action\0A\00"
@.str.2 = [8 x i8] c"--short\00"
@.str.3 = [37 x i8] c"Found --short .... take some action\0A\00"
define i32 @parse_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %7
7: ; preds = %36, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %39
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @equal(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %35
22: ; preds = %11
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @equal(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %34
33: ; preds = %22
store i32 -1, i32* %3
br label %40
34: ; preds = %30
br label %35
35: ; preds = %34, %19
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %7
39: ; preds = %7
store i32 0, i32* %3
br label %40
40: ; preds = %39, %33
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [7 x i8] c"--long\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"Found --long .... take some action\0A\00"
@.str.2 = [8 x i8] c"--short\00"
@.str.3 = [37 x i8] c"Found --short .... take some action\0A\00"
define i32 @parse_args(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %16
%7 = phi i64 [ 1, %4 ], [ %20, %16 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @equal(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i8*, i8** %8
%14 = tail call i64 @equal(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %12, %6
%17 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), %12 ]
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* %17)
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %12, %16, %2
%23 = phi i32 [ 0, %2 ], [ 0, %16 ], [ -1, %12 ]
ret i32 %23
}