#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__ isdigit(char);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
const char *normalize_arch(char *arch) {
  if (!strcmp(arch, "x86_64"))
    return "x86";
  if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
    return "x86";
  if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
    return "sparc";
  if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
    return "arm";
  if (!strncmp(arch, "s390", 4))
    return "s390";
  if (!strncmp(arch, "parisc", 6))
    return "parisc";
  if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
    return "powerpc";
  if (!strncmp(arch, "mips", 4))
    return "mips";
  if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
    return "sh";
  return arch;
}


x86 assembly (clang, -O0):
<normalize_arch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1165 <normalize_arch+0x35>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x69,%eax
jne    11a7 <normalize_arch+0x77>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x38,%eax
jne    11a7 <normalize_arch+0x77>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x36,%eax
jne    11a7 <normalize_arch+0x77>
lea    0xe69(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11de <normalize_arch+0xae>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ee <normalize_arch+0xbe>
lea    0xe2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1225 <normalize_arch+0xf5>
mov    -0x10(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1235 <normalize_arch+0x105>
lea    0xdeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xde1(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1263 <normalize_arch+0x133>
lea    0xdc7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1291 <normalize_arch+0x161>
lea    0xd9e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xd91(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     12cd <normalize_arch+0x19d>
mov    -0x10(%rbp),%rdi
lea    0xd7b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12dd <normalize_arch+0x1ad>
lea    0xd59(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xd51(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    130b <normalize_arch+0x1db>
lea    0xd37(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rdi
lea    0xd28(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1350 <normalize_arch+0x220>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1350 <normalize_arch+0x220>
lea    0xcf7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <normalize_arch+0x228>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_arch>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <strcmp@plt>
lea    0xebd(%rip),%r14
test   %eax,%eax
je     1289 <normalize_arch+0x159>
cmpb   $0x69,(%rbx)
jne    1167 <normalize_arch+0x37>
cmpb   $0x38,0x2(%rbx)
jne    1167 <normalize_arch+0x37>
cmpb   $0x36,0x3(%rbx)
je     1289 <normalize_arch+0x159>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
lea    0xe94(%rip),%r14
test   %eax,%eax
je     1289 <normalize_arch+0x159>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe73(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe47(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe2d(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe19(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xdf2(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <normalize_arch+0x159>
lea    0xddc(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     127b <normalize_arch+0x14b>
mov    %rbx,%r14
jmp    1289 <normalize_arch+0x159>
movsbl 0x2(%rbx),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     1276 <normalize_arch+0x146>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"x86_64\00"
@.str.1 = [4 x i8] c"x86\00"
@.str.2 = [6 x i8] c"sun4u\00"
@.str.3 = [6 x i8] c"sparc\00"
@.str.4 = [4 x i8] c"arm\00"
@.str.5 = [6 x i8] c"sa110\00"
@.str.6 = [5 x i8] c"s390\00"
@.str.7 = [7 x i8] c"parisc\00"
@.str.8 = [8 x i8] c"powerpc\00"
@.str.9 = [4 x i8] c"ppc\00"
@.str.10 = [5 x i8] c"mips\00"
@.str.11 = [3 x i8] c"sh\00"
define i8* @normalize_arch(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %82
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 105
br i1 %13, label %14, label %27
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 56
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 54
br i1 %25, label %26, label %27
26: ; preds = %20
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %82
27: ; preds = %20, %14, %8
%28 = load i8*, i8** %3
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31, %27
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %82
36: ; preds = %31
%37 = load i8*, i8** %3
%38 = call i32 @strncmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i8*, i8** %3
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %40, %36
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %82
45: ; preds = %40
%46 = load i8*, i8** %3
%47 = call i32 @strncmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %82
50: ; preds = %45
%51 = load i8*, i8** %3
%52 = call i32 @strncmp(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%53 = icmp ne i32 %52, 0
br i1 %53, label %55, label %54
54: ; preds = %50
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %82
55: ; preds = %50
%56 = load i8*, i8** %3
%57 = call i32 @strncmp(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i8*, i8** %3
%61 = call i32 @strncmp(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %59, %55
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %82
64: ; preds = %59
%65 = load i8*, i8** %3
%66 = call i32 @strncmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 4)
%67 = icmp ne i32 %66, 0
br i1 %67, label %69, label %68
68: ; preds = %64
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %82
69: ; preds = %64
%70 = load i8*, i8** %3
%71 = call i32 @strncmp(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%72 = icmp ne i32 %71, 0
br i1 %72, label %80, label %73
73: ; preds = %69
%74 = load i8*, i8** %3
%75 = getelementptr inbounds i8, i8* %74, i64 2
%76 = load i8, i8* %75
%77 = call i64 @isdigit(i8 signext %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %73
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %82
80: ; preds = %73, %69
%81 = load i8*, i8** %3
store i8* %81, i8** %2
br label %82
82: ; preds = %80, %79, %68, %63, %54, %49, %44, %35, %26, %7
%83 = load i8*, i8** %2
ret i8* %83
}

LLVM IR (-O2):
@.str = [7 x i8] c"x86_64\00"
@.str.1 = [4 x i8] c"x86\00"
@.str.2 = [6 x i8] c"sun4u\00"
@.str.3 = [6 x i8] c"sparc\00"
@.str.4 = [4 x i8] c"arm\00"
@.str.5 = [6 x i8] c"sa110\00"
@.str.6 = [5 x i8] c"s390\00"
@.str.7 = [7 x i8] c"parisc\00"
@.str.8 = [8 x i8] c"powerpc\00"
@.str.9 = [4 x i8] c"ppc\00"
@.str.10 = [5 x i8] c"mips\00"
@.str.11 = [3 x i8] c"sh\00"
define i8* @normalize_arch(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %51, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 105
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 56
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 54
br i1 %14, label %51, label %15
15: ; preds = %11, %7, %4
%16 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %51, label %18
18: ; preds = %15
%19 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %51, label %21
21: ; preds = %18
%22 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%23 = icmp eq i32 %22, 0
br i1 %23, label %51, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %51, label %27
27: ; preds = %24
%28 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %51, label %30
30: ; preds = %27
%31 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %51, label %33
33: ; preds = %30
%34 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%35 = icmp eq i32 %34, 0
br i1 %35, label %51, label %36
36: ; preds = %33
%37 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%38 = icmp eq i32 %37, 0
br i1 %38, label %51, label %39
39: ; preds = %36
%40 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %51, label %42
42: ; preds = %39
%43 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = getelementptr inbounds i8, i8* %0, i64 2
%47 = load i8, i8* %46
%48 = tail call i64 @isdigit(i8 signext %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %45, %42
br label %51
51: ; preds = %45, %39, %33, %36, %30, %27, %21, %24, %15, %18, %11, %1, %50
%52 = phi i8* [ %0, %50 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %15 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %24 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %21 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %27 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %30 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %36 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %33 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), %39 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), %45 ]
ret i8* %52
}