#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 */
struct utsname {
  char const *machine;
};

/* Variables and functions */
unsigned long EINVAL;
int /*<<< orphan*/ EXIT_FAILURE;
int PER_LINUX;
int PER_LINUX32;
int /*<<< orphan*/ SYS_personality;
int /*<<< orphan*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                         char const *);
scalar_t__ strcmp(char const *, char *);
scalar_t__ syscall(int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ uname(struct utsname *);
int set_arch(const char *pers, unsigned long options) {
  struct utsname un;
  int i;
  unsigned long pers_value, res;
  struct {
    int perval;
    const char *target_arch, *result_arch;
  } transitions[] = {{PER_LINUX32, "linux32", NULL},
                     {PER_LINUX, "linux64", NULL},
                     {PER_LINUX32, "i386", "i386"},
                     {PER_LINUX32, "i486", "i386"},
                     {PER_LINUX32, "i586", "i386"},
                     {PER_LINUX32, "i686", "i386"},
                     {PER_LINUX32, "athlon", "i386"},
                     {PER_LINUX, "x86_64", "x86_64"},
                     {-1, NULL, NULL}};
  for (i = 0; transitions[i].perval >= 0; i++)
    if (!strcmp(pers, transitions[i].target_arch))
      break;
  if (transitions[i].perval < 0)
    error(EXIT_FAILURE, 0, ("%s: Unrecognized architecture"), pers);
  pers_value = transitions[i].perval | options;
  res = ((long)syscall(SYS_personality, pers_value));
  if (res == -EINVAL)
    return 1;
  uname(&un);
  if (transitions[i].result_arch &&
      strcmp(un.machine, transitions[i].result_arch)) {
    if (strcmp(transitions[i].result_arch, "i386") ||
        (strcmp(un.machine, "i486") && strcmp(un.machine, "i586") &&
         strcmp(un.machine, "i686") && strcmp(un.machine, "athlon")))
      error(EXIT_FAILURE, 0, ("%s: Unrecognized architecture"), pers);
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_arch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x110(%rbp),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x110(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x108(%rbp)
movq   $0x0,-0x100(%rbp)
add    $0x18,%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf8(%rbp)
lea    0xe5c(%rip),%rax
mov    %rax,-0xf0(%rbp)
movq   $0x0,-0xe8(%rbp)
add    $0x18,%rdi
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe0(%rbp)
lea    0xe38(%rip),%rax
mov    %rax,-0xd8(%rbp)
lea    0xe2a(%rip),%rax
mov    %rax,-0xd0(%rbp)
add    $0x18,%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
lea    0xe0e(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xdfb(%rip),%rax
mov    %rax,-0xb8(%rbp)
add    $0x18,%rdi
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
lea    0xde4(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    0xdcc(%rip),%rax
mov    %rax,-0xa0(%rbp)
add    $0x18,%rdi
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
lea    0xdba(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xd9d(%rip),%rax
mov    %rax,-0x88(%rbp)
add    $0x18,%rdi
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
lea    0xd93(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xd74(%rip),%rax
mov    %rax,-0x70(%rbp)
add    $0x18,%rdi
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
lea    0xd74(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xd69(%rip),%rax
mov    %rax,-0x58(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0xffffffff,-0x50(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,(%rax)
jl     1340 <set_arch+0x1f0>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    132d <set_arch+0x1dd>
jmp    1340 <set_arch+0x1f0>
jmp    1332 <set_arch+0x1e2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12e4 <set_arch+0x194>
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,(%rax)
jge    1376 <set_arch+0x226>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
xor    %esi,%esi
lea    0xcc1(%rip),%rdx
call   1070 <error@plt>
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq (%rax),%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
call   1060 <syscall@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
xor    %ecx,%ecx
mov    0x2c0a(%rip),%rdx
sub    (%rdx),%rcx
cmp    %rcx,%rax
jne    13ce <set_arch+0x27e>
movl   $0x1,-0x4(%rbp)
jmp    14d8 <set_arch+0x388>
lea    -0x20(%rbp),%rdi
call   1030 <uname@plt>
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpq   $0x0,0x10(%rax)
je     14d1 <set_arch+0x381>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14d1 <set_arch+0x381>
movslq -0x24(%rbp),%rcx
lea    -0x110(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rdi
lea    0xbd6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    14b1 <set_arch+0x361>
mov    -0x20(%rbp),%rdi
lea    0xbc1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14cc <set_arch+0x37c>
mov    -0x20(%rbp),%rdi
lea    0xbac(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14cc <set_arch+0x37c>
mov    -0x20(%rbp),%rdi
lea    0xb97(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14cc <set_arch+0x37c>
mov    -0x20(%rbp),%rdi
lea    0xb82(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     14cc <set_arch+0x37c>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
xor    %esi,%esi
lea    0xb6b(%rip),%rdx
call   1070 <error@plt>
jmp    14d1 <set_arch+0x381>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_arch>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf0,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0xe97(%rip),%rcx
mov    %rcx,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    0x2e5a(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x28(%rsp)
lea    0xe7d(%rip),%rdx
mov    %rdx,0x30(%rsp)
movq   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
lea    0xe6c(%rip),%rdx
mov    %rdx,0x48(%rsp)
mov    %rdx,0x50(%rsp)
mov    %eax,0x58(%rsp)
lea    0xe5c(%rip),%rsi
mov    %rsi,0x60(%rsp)
mov    %rdx,0x68(%rsp)
mov    %eax,0x70(%rsp)
lea    0xe4c(%rip),%rsi
mov    %rsi,0x78(%rsp)
mov    %rdx,0x80(%rsp)
mov    %eax,0x88(%rsp)
lea    0xe36(%rip),%rsi
mov    %rsi,0x90(%rsp)
mov    %rdx,0x98(%rsp)
mov    %eax,0xa0(%rsp)
lea    0xe1d(%rip),%rsi
mov    %rsi,0xa8(%rsp)
mov    %rdx,0xb0(%rsp)
mov    %ecx,0xb8(%rsp)
lea    0xe06(%rip),%rcx
mov    %rcx,0xc0(%rsp)
mov    %rcx,0xc8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movq   $0x0,0xe0(%rsp)
movl   $0xffffffff,0xd0(%rsp)
ff ff ff ff
test   %eax,%eax
js     12a7 <set_arch+0x167>
lea    0xd9e(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12b0 <set_arch+0x170>
lea    0x28(%rsp),%rbx
mov    $0x1,%ebp
nopl   0x0(%rax)
cmpl   $0x0,(%rbx)
js     12bf <set_arch+0x17f>
mov    0x8(%rbx),%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
add    $0x1,%rbp
add    $0x18,%rbx
test   %rax,%rax
jne    1280 <set_arch+0x140>
add    $0xffffffff,%ebp
add    $0xffffffffffffffe8,%rbx
jmp    12b7 <set_arch+0x177>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
jmp    12c1 <set_arch+0x181>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    (%rbx),%eax
test   %eax,%eax
jns    12dd <set_arch+0x19d>
jmp    12c1 <set_arch+0x181>
mov    %ebp,%ebp
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rdx
xor    %esi,%esi
mov    %r12,%rcx
call   1060 <error@plt>
mov    (%rbx),%eax
movslq %eax,%rsi
or     %r14,%rsi
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
call   1050 <syscall@plt>
mov    0x2cc8(%rip),%rcx
mov    $0x1,%r15d
add    (%rcx),%rax
je     136b <set_arch+0x22b>
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
mov    0x20(%rsp,%rax,8),%rbp
xor    %r15d,%r15d
test   %rbp,%rbp
je     136b <set_arch+0x22b>
mov    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     136b <set_arch+0x22b>
lea    0xccf(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     137e <set_arch+0x23e>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
lea    0xcd4(%rip),%rdx
xor    %r15d,%r15d
xor    %esi,%esi
mov    %r12,%rcx
call   1060 <error@plt>
mov    %r15d,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc90(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     136b <set_arch+0x22b>
lea    0xc81(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     136b <set_arch+0x22b>
lea    0xc72(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     136b <set_arch+0x22b>
lea    0xc63(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    134e <set_arch+0x20e>
jmp    136b <set_arch+0x22b>

LLVM IR (-O0):
%struct.utsname = type { i8* }
%struct.anon = type { i32, i8*, i8* }
@PER_LINUX32 = global i32 0
@.str = [8 x i8] c"linux32\00"
@PER_LINUX = global i32 0
@.str.1 = [8 x i8] c"linux64\00"
@.str.2 = [5 x i8] c"i386\00"
@.str.3 = [5 x i8] c"i486\00"
@.str.4 = [5 x i8] c"i586\00"
@.str.5 = [5 x i8] c"i686\00"
@.str.6 = [7 x i8] c"athlon\00"
@.str.7 = [7 x i8] c"x86_64\00"
@EXIT_FAILURE = global i32 0
@.str.8 = [30 x i8] c"%s: Unrecognized architecture\00"
@SYS_personality = global i32 0
@EINVAL = global i64 0
define i32 @set_arch(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.utsname
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca [9 x %struct.anon]
store i8* %0, i8** %4
store i64 %1, i64* %5
%11 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 0
%12 = getelementptr inbounds %struct.anon, %struct.anon* %11, i32 0, i32 0
%13 = load i32, i32* @PER_LINUX32
store i32 %13, i32* %12
%14 = getelementptr inbounds %struct.anon, %struct.anon* %11, i32 0, i32 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds %struct.anon, %struct.anon* %11, i32 0, i32 2
store i8* null, i8** %15
%16 = getelementptr inbounds %struct.anon, %struct.anon* %11, i64 1
%17 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 0
%18 = load i32, i32* @PER_LINUX
store i32 %18, i32* %17
%19 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 2
store i8* null, i8** %20
%21 = getelementptr inbounds %struct.anon, %struct.anon* %16, i64 1
%22 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 0, i32 0
%23 = load i32, i32* @PER_LINUX32
store i32 %23, i32* %22
%24 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds %struct.anon, %struct.anon* %21, i64 1
%27 = getelementptr inbounds %struct.anon, %struct.anon* %26, i32 0, i32 0
%28 = load i32, i32* @PER_LINUX32
store i32 %28, i32* %27
%29 = getelementptr inbounds %struct.anon, %struct.anon* %26, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds %struct.anon, %struct.anon* %26, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds %struct.anon, %struct.anon* %26, i64 1
%32 = getelementptr inbounds %struct.anon, %struct.anon* %31, i32 0, i32 0
%33 = load i32, i32* @PER_LINUX32
store i32 %33, i32* %32
%34 = getelementptr inbounds %struct.anon, %struct.anon* %31, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds %struct.anon, %struct.anon* %31, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %35
%36 = getelementptr inbounds %struct.anon, %struct.anon* %31, i64 1
%37 = getelementptr inbounds %struct.anon, %struct.anon* %36, i32 0, i32 0
%38 = load i32, i32* @PER_LINUX32
store i32 %38, i32* %37
%39 = getelementptr inbounds %struct.anon, %struct.anon* %36, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %39
%40 = getelementptr inbounds %struct.anon, %struct.anon* %36, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %40
%41 = getelementptr inbounds %struct.anon, %struct.anon* %36, i64 1
%42 = getelementptr inbounds %struct.anon, %struct.anon* %41, i32 0, i32 0
%43 = load i32, i32* @PER_LINUX32
store i32 %43, i32* %42
%44 = getelementptr inbounds %struct.anon, %struct.anon* %41, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %44
%45 = getelementptr inbounds %struct.anon, %struct.anon* %41, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %45
%46 = getelementptr inbounds %struct.anon, %struct.anon* %41, i64 1
%47 = getelementptr inbounds %struct.anon, %struct.anon* %46, i32 0, i32 0
%48 = load i32, i32* @PER_LINUX
store i32 %48, i32* %47
%49 = getelementptr inbounds %struct.anon, %struct.anon* %46, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %49
%50 = getelementptr inbounds %struct.anon, %struct.anon* %46, i32 0, i32 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %50
%51 = getelementptr inbounds %struct.anon, %struct.anon* %46, i64 1
%52 = bitcast %struct.anon* %51 to i8*
%53 = getelementptr inbounds %struct.anon, %struct.anon* %51, i32 0, i32 0
store i32 -1, i32* %53
store i32 0, i32* %7
br label %54
54: ; preds = %72, %2
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %56
%58 = getelementptr inbounds %struct.anon, %struct.anon* %57, i32 0, i32 0
%59 = load i32, i32* %58
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %75
61: ; preds = %54
%62 = load i8*, i8** %4
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %64
%66 = getelementptr inbounds %struct.anon, %struct.anon* %65, i32 0, i32 1
%67 = load i8*, i8** %66
%68 = call i64 @strcmp(i8* %62, i8* %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %61
br label %75
71: ; preds = %61
br label %72
72: ; preds = %71
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %54
75: ; preds = %70, %54
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %77
%79 = getelementptr inbounds %struct.anon, %struct.anon* %78, i32 0, i32 0
%80 = load i32, i32* %79
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %75
%83 = load i32, i32* @EXIT_FAILURE
%84 = load i8*, i8** %4
%85 = call i32 @error(i32 %83, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %82, %75
%87 = load i32, i32* %7
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %88
%90 = getelementptr inbounds %struct.anon, %struct.anon* %89, i32 0, i32 0
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = load i64, i64* %5
%94 = or i64 %92, %93
store i64 %94, i64* %8
%95 = load i32, i32* @SYS_personality
%96 = load i64, i64* %8
%97 = call i64 @syscall(i32 %95, i64 %96)
store i64 %97, i64* %9
%98 = load i64, i64* %9
%99 = load i64, i64* @EINVAL
%100 = sub i64 0, %99
%101 = icmp eq i64 %98, %100
br i1 %101, label %102, label %103
102: ; preds = %86
store i32 1, i32* %3
br label %155
103: ; preds = %86
%104 = call i32 @uname(%struct.utsname* %6)
%105 = load i32, i32* %7
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %106
%108 = getelementptr inbounds %struct.anon, %struct.anon* %107, i32 0, i32 2
%109 = load i8*, i8** %108
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %154
111: ; preds = %103
%112 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%113 = load i8*, i8** %112
%114 = load i32, i32* %7
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %115
%117 = getelementptr inbounds %struct.anon, %struct.anon* %116, i32 0, i32 2
%118 = load i8*, i8** %117
%119 = call i64 @strcmp(i8* %113, i8* %118)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %154
121: ; preds = %111
%122 = load i32, i32* %7
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %10, i64 0, i64 %123
%125 = getelementptr inbounds %struct.anon, %struct.anon* %124, i32 0, i32 2
%126 = load i8*, i8** %125
%127 = call i64 @strcmp(i8* %126, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%128 = icmp ne i64 %127, 0
br i1 %128, label %149, label %129
129: ; preds = %121
%130 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%131 = load i8*, i8** %130
%132 = call i64 @strcmp(i8* %131, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%133 = icmp ne i64 %132, 0
br i1 %133, label %134, label %153
134: ; preds = %129
%135 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%136 = load i8*, i8** %135
%137 = call i64 @strcmp(i8* %136, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %153
139: ; preds = %134
%140 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%141 = load i8*, i8** %140
%142 = call i64 @strcmp(i8* %141, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%143 = icmp ne i64 %142, 0
br i1 %143, label %144, label %153
144: ; preds = %139
%145 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%146 = load i8*, i8** %145
%147 = call i64 @strcmp(i8* %146, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%148 = icmp ne i64 %147, 0
br i1 %148, label %149, label %153
149: ; preds = %144, %121
%150 = load i32, i32* @EXIT_FAILURE
%151 = load i8*, i8** %4
%152 = call i32 @error(i32 %150, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %151)
br label %153
153: ; preds = %149, %144, %139, %134, %129
br label %154
154: ; preds = %153, %111, %103
store i32 0, i32* %3
br label %155
155: ; preds = %154, %102
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
%struct.anon = type { i32, i8*, i8* }
@PER_LINUX32 = global i32 0
@.str = [8 x i8] c"linux32\00"
@PER_LINUX = global i32 0
@.str.1 = [8 x i8] c"linux64\00"
@.str.2 = [5 x i8] c"i386\00"
@.str.3 = [5 x i8] c"i486\00"
@.str.4 = [5 x i8] c"i586\00"
@.str.5 = [5 x i8] c"i686\00"
@.str.6 = [7 x i8] c"athlon\00"
@.str.7 = [7 x i8] c"x86_64\00"
@EXIT_FAILURE = global i32 0
@.str.8 = [30 x i8] c"%s: Unrecognized architecture\00"
@SYS_personality = global i32 0
@EINVAL = global i64 0
define i32 @set_arch(i8* %0, i64 %1) {
%3 = alloca %struct.utsname
%4 = alloca [9 x %struct.anon]
%5 = bitcast %struct.utsname* %3 to i8*
%6 = bitcast [9 x %struct.anon]* %4 to i8*
%7 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 0, i32 0
%8 = load i32, i32* @PER_LINUX32
store i32 %8, i32* %7
%9 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 0, i32 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 0, i32 2
store i8* null, i8** %10
%11 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 1, i32 0
%12 = load i32, i32* @PER_LINUX
store i32 %12, i32* %11
%13 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 1, i32 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 1, i32 2
store i8* null, i8** %14
%15 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 2, i32 0
store i32 %8, i32* %15
%16 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 2, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 2, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 3, i32 0
store i32 %8, i32* %18
%19 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 3, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 3, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 4, i32 0
store i32 %8, i32* %21
%22 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 4, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 4, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 5, i32 0
store i32 %8, i32* %24
%25 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 5, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 5, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 6, i32 0
store i32 %8, i32* %27
%28 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 6, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 6, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 7, i32 0
store i32 %12, i32* %30
%31 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 7, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 7, i32 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %32
%33 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 8
%34 = bitcast %struct.anon* %33 to i8*
%35 = getelementptr inbounds %struct.anon, %struct.anon* %33, i64 0, i32 0
store i32 -1, i32* %35
%36 = icmp sgt i32 %8, -1
br i1 %36, label %37, label %60
37: ; preds = %2
%38 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %53, label %40
40: ; preds = %37, %46
%41 = phi i64 [ %42, %46 ], [ 0, %37 ]
%42 = add nuw i64 %41, 1
%43 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 %42, i32 0
%44 = load i32, i32* %43
%45 = icmp sgt i32 %44, -1
br i1 %45, label %46, label %58
46: ; preds = %40
%47 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 %42, i32 1
%48 = load i8*, i8** %47
%49 = tail call i64 @strcmp(i8* %0, i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %40
51: ; preds = %46
%52 = and i64 %42, 4294967295
br label %53
53: ; preds = %51, %37
%54 = phi i64 [ %52, %51 ], [ 0, %37 ]
%55 = phi i32* [ %43, %51 ], [ %7, %37 ]
%56 = load i32, i32* %55
%57 = icmp slt i32 %56, 0
br i1 %57, label %60, label %66
58: ; preds = %40
%59 = and i64 %42, 4294967295
br label %60
60: ; preds = %2, %58, %53
%61 = phi i64 [ %54, %53 ], [ 0, %2 ], [ %59, %58 ]
%62 = phi i32* [ %55, %53 ], [ %7, %2 ], [ %43, %58 ]
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @error(i32 %63, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%65 = load i32, i32* %62
br label %66
66: ; preds = %60, %53
%67 = phi i32 [ %65, %60 ], [ %56, %53 ]
%68 = phi i64 [ %61, %60 ], [ %54, %53 ]
%69 = sext i32 %67 to i64
%70 = or i64 %69, %1
%71 = load i32, i32* @SYS_personality
%72 = tail call i64 @syscall(i32 %71, i64 %70)
%73 = load i64, i64* @EINVAL
%74 = sub i64 0, %73
%75 = icmp eq i64 %72, %74
br i1 %75, label %104, label %76
76: ; preds = %66
%77 = call i32 @uname(%struct.utsname* %3)
%78 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* %4, i64 0, i64 %68, i32 2
%79 = load i8*, i8** %78
%80 = icmp eq i8* %79, null
br i1 %80, label %104, label %81
81: ; preds = %76
%82 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%83 = load i8*, i8** %82
%84 = tail call i64 @strcmp(i8* %83, i8* %79)
%85 = icmp eq i64 %84, 0
br i1 %85, label %104, label %86
86: ; preds = %81
%87 = tail call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %101
89: ; preds = %86
%90 = tail call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %104, label %92
92: ; preds = %89
%93 = tail call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %104, label %95
95: ; preds = %92
%96 = tail call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
br i1 %97, label %104, label %98
98: ; preds = %95
%99 = tail call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %104, label %101
101: ; preds = %98, %86
%102 = load i32, i32* @EXIT_FAILURE
%103 = tail call i32 @error(i32 %102, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %104
104: ; preds = %76, %81, %101, %98, %95, %92, %89, %66
%105 = phi i32 [ 1, %66 ], [ 0, %89 ], [ 0, %92 ], [ 0, %95 ], [ 0, %98 ], [ 0, %101 ], [ 0, %81 ], [ 0, %76 ]
ret i32 %105
}