#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__ strcmp(char *, char *);
int interpreteFlags(int argc, char **argv) {
  int i, res;
  res = 0;
  for (i = 1; i < argc - 1; i++) {
    if (strcmp(argv[i], "-a") == 0) {
      res |= 0x0001;
    } else if (strcmp(argv[i], "-c") == 0) {
      res |= 0x0002;
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<interpreteFlags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b1 <interpreteFlags+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116e <interpreteFlags+0x5e>
mov    -0x18(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119e <interpreteFlags+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1199 <interpreteFlags+0x89>
mov    -0x18(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    119e <interpreteFlags+0x8e>
jmp    11a3 <interpreteFlags+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <interpreteFlags+0x1d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpreteFlags>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x3,%edi
jl     1188 <interpreteFlags+0x78>
mov    %rsi,%r13
mov    %edi,%r14d
add    $0xffffffff,%r14d
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0xec6(%rip),%r15
lea    0xec2(%rip),%r12
jmp    1171 <interpreteFlags+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
mov    %ebp,%ecx
or     $0x2,%ecx
test   %rax,%rax
cmove  %ecx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
je     1188 <interpreteFlags+0x78>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1150 <interpreteFlags+0x40>
or     $0x1,%ebp
jmp    1168 <interpreteFlags+0x58>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-a\00"
@.str.1 = [3 x i8] c"-c\00"
define i32 @interpreteFlags(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
store i32 1, i32* %5
br label %7
7: ; preds = %36, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %39
12: ; preds = %7
%13 = load i8**, i8*** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32, i32* %6
%22 = or i32 %21, 1
store i32 %22, i32* %6
br label %35
23: ; preds = %12
%24 = load i8**, i8*** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load i32, i32* %6
%33 = or i32 %32, 2
store i32 %33, i32* %6
br label %34
34: ; preds = %31, %23
br label %35
35: ; preds = %34, %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %7
39: ; preds = %7
%40 = load i32, i32* %6
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"-a\00"
@.str.1 = [3 x i8] c"-c\00"
define i32 @interpreteFlags(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %22
%8 = phi i64 [ 1, %4 ], [ %24, %22 ]
%9 = phi i32 [ 0, %4 ], [ %23, %22 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = or i32 %9, 1
br label %22
16: ; preds = %7
%17 = load i8*, i8** %10
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = or i32 %9, 2
%21 = select i1 %19, i32 %20, i32 %9
br label %22
22: ; preds = %16, %14
%23 = phi i32 [ %15, %14 ], [ %21, %16 ]
%24 = add nuw nsw i64 %8, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %7
26: ; preds = %22, %2
%27 = phi i32 [ 0, %2 ], [ %23, %22 ]
ret i32 %27
}