#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 *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int get_attributes(int argc, char **argv) {
  int i;
  unsigned int attributes = 0;
  for (i = 1; i < argc; ++i) {
    if (!strcmp(argv[i], "tv")) {
      attributes |= (1 << 4);
    } else if (!strcmp(argv[i], "avx")) {
      attributes |= (1 << 1);
    } else if (!strcmp(argv[i], "sse")) {
      attributes |= (1 << 0);
    } else if (!strcmp(argv[i], "avx2")) {
      attributes |= (1 << 2);
    } else {
      printf("Unrecognised attribute: %s\n", argv[i]);
      exit(1);
    }
  }
  return attributes;
}


x86 assembly (clang, -O0):
<get_attributes>:
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
cmp    -0x4(%rbp),%eax
jge    1259 <get_attributes+0x129>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe94(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1188 <get_attributes+0x58>
mov    -0x18(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x18(%rbp)
jmp    1246 <get_attributes+0x116>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <get_attributes+0x87>
mov    -0x18(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1241 <get_attributes+0x111>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <get_attributes+0xb6>
mov    -0x18(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123c <get_attributes+0x10c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe12(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1215 <get_attributes+0xe5>
mov    -0x18(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    1237 <get_attributes+0x107>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    123c <get_attributes+0x10c>
jmp    1241 <get_attributes+0x111>
jmp    1246 <get_attributes+0x116>
jmp    124b <get_attributes+0x11b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <get_attributes+0x1d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_attributes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     11de <get_attributes+0xae>
mov    %rsi,%rbx
mov    %edi,%r12d
xor    %ebp,%ebp
mov    $0x1,%r15d
lea    0xea5(%rip),%r14
jmp    1170 <get_attributes+0x40>
nopl   (%rax)
mov    $0x10,%ecx
or     %ecx,%ebp
add    $0x1,%r15
cmp    %r15,%r12
je     11de <get_attributes+0xae>
mov    (%rbx,%r15,8),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1160 <get_attributes+0x30>
mov    %r13,%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d0 <get_attributes+0xa0>
mov    %r13,%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d7 <get_attributes+0xa7>
mov    %r13,%rdi
lea    0xe58(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x4,%ecx
test   %eax,%eax
je     1165 <get_attributes+0x35>
jmp    11ef <get_attributes+0xbf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2,%ecx
jmp    1165 <get_attributes+0x35>
mov    $0x1,%ecx
jmp    1165 <get_attributes+0x35>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1a(%rip),%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"tv\00"
@.str.1 = [4 x i8] c"avx\00"
@.str.2 = [4 x i8] c"sse\00"
@.str.3 = [5 x i8] c"avx2\00"
@.str.4 = [28 x i8] c"Unrecognised attribute: %s\0A\00"
define i32 @get_attributes(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 = %67, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %70
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 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %11
%20 = load i32, i32* %6
%21 = or i32 %20, 16
store i32 %21, i32* %6
br label %66
22: ; preds = %11
%23 = load i8**, i8*** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %22
%31 = load i32, i32* %6
%32 = or i32 %31, 2
store i32 %32, i32* %6
br label %65
33: ; preds = %22
%34 = load i8**, i8*** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %33
%42 = load i32, i32* %6
%43 = or i32 %42, 1
store i32 %43, i32* %6
br label %64
44: ; preds = %33
%45 = load i8**, i8*** %4
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %55, label %52
52: ; preds = %44
%53 = load i32, i32* %6
%54 = or i32 %53, 4
store i32 %54, i32* %6
br label %63
55: ; preds = %44
%56 = load i8**, i8*** %4
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %52
br label %64
64: ; preds = %63, %41
br label %65
65: ; preds = %64, %30
br label %66
66: ; preds = %65, %19
br label %67
67: ; preds = %66
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %7
70: ; preds = %7
%71 = load i32, i32* %6
ret i32 %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"tv\00"
@.str.1 = [4 x i8] c"avx\00"
@.str.2 = [4 x i8] c"sse\00"
@.str.3 = [5 x i8] c"avx2\00"
@.str.4 = [28 x i8] c"Unrecognised attribute: %s\0A\00"
define i32 @get_attributes(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %30
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %25
%7 = phi i64 [ 1, %4 ], [ %28, %25 ]
%8 = phi i32 [ 0, %4 ], [ %27, %25 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %6
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %19, %16, %13, %6
%26 = phi i32 [ 16, %6 ], [ 2, %13 ], [ 1, %16 ], [ 4, %19 ]
%27 = or i32 %8, %26
%28 = add nuw nsw i64 %7, 1
%29 = icmp eq i64 %28, %5
br i1 %29, label %30, label %6
30: ; preds = %25, %2
%31 = phi i32 [ 0, %2 ], [ %27, %25 ]
ret i32 %31
}