#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 *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int parse_args(int argc, char **argv) {
  int i;
  for (i = 1; i < argc; i++) {
    if (strncmp(argv[i], "--list", strlen("--list")) == 0) {
      printf(" * Using long listing\n");
    } else {
      fprintf(stderr, " * unknown option: '%s'\n", argv[i]);
      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    11eb <parse_args+0xab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe75(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ab <parse_args+0x6b>
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
jmp    11d8 <parse_args+0x98>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe57(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f2 <parse_args+0xb2>
jmp    11dd <parse_args+0x9d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <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     11c1 <parse_args+0x81>
mov    %rsi,%r12
mov    %edi,%r14d
mov    $0x1,%ebp
lea    0xe9c(%rip),%r13
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11a3 <parse_args+0x63>
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1170 <parse_args+0x30>
xor    %eax,%eax
jmp    11c1 <parse_args+0x81>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%rbp,8),%rdx
lea    0xe50(%rip),%rsi
call   1060 <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"--list\00"
@.str.1 = [23 x i8] c" * Using long listing\0A\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c" * unknown option: '%s'\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 = %31, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
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 i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %30
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %28)
store i32 1, i32* %3
br label %35
30: ; preds = %20
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %7
34: ; preds = %7
store i32 0, i32* %3
br label %35
35: ; preds = %34, %22
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [7 x i8] c"--list\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c" * unknown option: '%s'\0A\00"
@str = [22 x i8] c" * Using long listing\00"
define i32 @parse_args(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %13
%7 = phi i64 [ 1, %4 ], [ %15, %13 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = tail call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %23, label %6
17: ; preds = %6
%18 = and i64 %7, 4294967295
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %19
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %13, %2, %17
%24 = phi i32 [ 1, %17 ], [ 0, %2 ], [ 0, %13 ]
ret i32 %24
}