#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int determine_switches(int argc, char *argv) {
  int i;
  int status = 1;
  for (i = 0; i < argc; ++i) {
    switch (argv[i]) {
    case 'l':
      status *= 3;
      break;
    case 'a':
      status *= 5;
      break;
    case 'v':
      status *= 7;
      break;
    default:
      if (argc == 0) {
      } else {
        printf("Invalid switch statements, must be either l, a, or v. Code: "
               "1238747");
        exit(-1);
      }
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<determine_switches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e9 <determine_switches+0xc9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x61,%eax
je     1194 <determine_switches+0x74>
jmp    1166 <determine_switches+0x46>
mov    -0x1c(%rbp),%eax
sub    $0x6c,%eax
je     1188 <determine_switches+0x68>
jmp    1177 <determine_switches+0x57>
mov    -0x1c(%rbp),%eax
sub    $0x76,%eax
je     11a0 <determine_switches+0x80>
jmp    11ac <determine_switches+0x8c>
imul   $0x3,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <determine_switches+0xb6>
imul   $0x5,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <determine_switches+0xb6>
imul   $0x7,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <determine_switches+0xb6>
cmpl   $0x0,-0x4(%rbp)
jne    11bb <determine_switches+0x9b>
jmp    11d1 <determine_switches+0xb1>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
jmp    11d6 <determine_switches+0xb6>
jmp    11db <determine_switches+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <determine_switches+0x1d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_switches>:
push   %rax
test   %edi,%edi
jle    1172 <determine_switches+0x52>
mov    %edi,%r8d
mov    $0x1,%eax
xor    %edx,%edx
jmp    1151 <determine_switches+0x31>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x7,%edi
imul   %edi,%eax
add    $0x1,%rdx
cmp    %rdx,%r8
je     1170 <determine_switches+0x50>
movsbl (%rsi,%rdx,1),%ecx
cmp    $0x76,%ecx
je     1140 <determine_switches+0x20>
mov    $0x3,%edi
cmp    $0x6c,%ecx
je     1145 <determine_switches+0x25>
cmp    $0x61,%ecx
jne    1179 <determine_switches+0x59>
mov    $0x5,%edi
jmp    1145 <determine_switches+0x25>
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [68 x i8] c"Invalid switch statements, must be either l, a, or v. Code: 1238747\00"
define i32 @determine_switches(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 1, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %36, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %39
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %27 [
i32 108, label %18
i32 97, label %21
i32 118, label %24
]
18: ; preds = %11
%19 = load i32, i32* %6
%20 = mul nsw i32 %19, 3
store i32 %20, i32* %6
br label %35
21: ; preds = %11
%22 = load i32, i32* %6
%23 = mul nsw i32 %22, 5
store i32 %23, i32* %6
br label %35
24: ; preds = %11
%25 = load i32, i32* %6
%26 = mul nsw i32 %25, 7
store i32 %26, i32* %6
br label %35
27: ; preds = %11
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
br label %34
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %30
br label %35
35: ; preds = %34, %24, %21, %18
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 = [68 x i8] c"Invalid switch statements, must be either l, a, or v. Code: 1238747\00"
define i32 @determine_switches(i32 %0, i8* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %17
%7 = phi i64 [ 0, %4 ], [ %20, %17 ]
%8 = phi i32 [ 1, %4 ], [ %19, %17 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %7
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %14 [
i32 108, label %17
i32 97, label %12
i32 118, label %13
]
12: ; preds = %6
br label %17
13: ; preds = %6
br label %17
14: ; preds = %6
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %6, %12, %13
%18 = phi i32 [ 5, %12 ], [ 7, %13 ], [ 3, %6 ]
%19 = mul nsw i32 %8, %18
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %17, %2
%23 = phi i32 [ 1, %2 ], [ %19, %17 ]
ret i32 %23
}