#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*/ maxi(int, int);
int /*<<< orphan*/ strcmp(char const *, char *);
int type2weight(char const *);
char const *weight2type(int /*<<< orphan*/);
const char *find_gct(const char *op, const char *type1, const char *type2) {
  int w1, w2;
  if (!strcmp(type1, "xs_untypedAtomic") &&
      !strcmp(type2, "xs_untypedAtomic")) {
    if (!strcmp(op, "idiv"))
      return "xs_integer";
    else
      return "xs_double";
  } else if (!strcmp(type1, "xs_untypedAtomic")) {
    if (!strcmp(op, "idiv"))
      return find_gct(op, "xs_integer", type2);
    else
      return find_gct(op, "xs_double", type2);
  } else if (!strcmp(type2, "xs_untypedAtomic")) {
    if (!strcmp(op, "idiv"))
      return find_gct(op, type1, "xs_integer");
    else
      return find_gct(op, type1, "xs_double");
  } else {
    w1 = type2weight(type1);
    w2 = type2weight(type2);
    if (w1 == -1 || w2 == -1)
      return NULL;
    return weight2type(maxi(w1, w2));
  }
}


x86 assembly (clang, -O0):
<find_gct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11cf <find_gct+0x7f>
mov    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11cf <find_gct+0x7f>
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11bf <find_gct+0x6f>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x18(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    123b <find_gct+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    121e <find_gct+0xce>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe06(%rip),%rsi
call   1040 <find_gct@plt>
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdf4(%rip),%rsi
call   1040 <find_gct@plt>
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x20(%rbp),%rdi
lea    0xdba(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12a7 <find_gct+0x157>
mov    -0x10(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    128a <find_gct+0x13a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xd9a(%rip),%rdx
call   1040 <find_gct@plt>
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xd88(%rip),%rdx
call   1040 <find_gct@plt>
mov    %rax,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x18(%rbp),%rdi
call   1070 <type2weight@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <type2weight@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     12d3 <find_gct+0x183>
cmpl   $0xffffffff,-0x28(%rbp)
jne    12e0 <find_gct+0x190>
movq   $0x0,-0x8(%rbp)
jmp    12f6 <find_gct+0x1a6>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <maxi@plt>
mov    %eax,%edi
call   1030 <weight2type@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_gct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xea8(%rip),%r12
mov    %rdx,(%rsp)
mov    %rdx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
mov    %eax,%ebp
lea    0xea1(%rip),%r13
lea    0xe9f(%rip),%r14
jmp    1188 <find_gct+0x48>
nopl   0x0(%rax)
test   %ebp,%ebp
je     1233 <find_gct+0xf3>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11b2 <find_gct+0x72>
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    %r14,%rbx
test   %eax,%eax
je     1180 <find_gct+0x40>
lea    0xe71(%rip),%rbx
jmp    1180 <find_gct+0x40>
test   %ebp,%ebp
mov    (%rsp),%rbp
jne    11f4 <find_gct+0xb4>
lea    0xe50(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
lea    0xe44(%rip),%rax
lea    0xe48(%rip),%rbp
cmove  %rax,%rbp
lea    0xe1c(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
nopl   0x0(%rax)
test   %eax,%eax
je     11f0 <find_gct+0xb0>
mov    %rbx,%rdi
call   1060 <type2weight@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1060 <type2weight@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%r14d
je     1233 <find_gct+0xf3>
cmp    $0xffffffff,%eax
je     1233 <find_gct+0xf3>
mov    %r14d,%edi
mov    %eax,%esi
call   1050 <maxi@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <weight2type@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"xs_untypedAtomic\00"
@.str.1 = [5 x i8] c"idiv\00"
@.str.2 = [11 x i8] c"xs_integer\00"
@.str.3 = [10 x i8] c"xs_double\00"
define i8* @find_gct(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %6
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %71
22: ; preds = %17
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %71
23: ; preds = %13, %3
%24 = load i8*, i8** %6
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %39, label %27
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i8*, i8** %5
%33 = load i8*, i8** %7
%34 = call i8* @find_gct(i8* %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i8* %34, i8** %4
br label %71
35: ; preds = %27
%36 = load i8*, i8** %5
%37 = load i8*, i8** %7
%38 = call i8* @find_gct(i8* %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %37)
store i8* %38, i8** %4
br label %71
39: ; preds = %23
%40 = load i8*, i8** %7
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %55, label %43
43: ; preds = %39
%44 = load i8*, i8** %5
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i8*, i8** %5
%49 = load i8*, i8** %6
%50 = call i8* @find_gct(i8* %48, i8* %49, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %50, i8** %4
br label %71
51: ; preds = %43
%52 = load i8*, i8** %5
%53 = load i8*, i8** %6
%54 = call i8* @find_gct(i8* %52, i8* %53, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* %54, i8** %4
br label %71
55: ; preds = %39
%56 = load i8*, i8** %6
%57 = call i32 @type2weight(i8* %56)
store i32 %57, i32* %8
%58 = load i8*, i8** %7
%59 = call i32 @type2weight(i8* %58)
store i32 %59, i32* %9
%60 = load i32, i32* %8
%61 = icmp eq i32 %60, -1
br i1 %61, label %65, label %62
62: ; preds = %55
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %66
65: ; preds = %62, %55
store i8* null, i8** %4
br label %71
66: ; preds = %62
%67 = load i32, i32* %8
%68 = load i32, i32* %9
%69 = call i32 @maxi(i32 %67, i32 %68)
%70 = call i8* @weight2type(i32 %69)
store i8* %70, i8** %4
br label %71
71: ; preds = %66, %65, %51, %47, %35, %31, %22, %21
%72 = load i8*, i8** %4
ret i8* %72
}

LLVM IR (-O2):
@.str = [17 x i8] c"xs_untypedAtomic\00"
@.str.1 = [5 x i8] c"idiv\00"
@.str.2 = [11 x i8] c"xs_integer\00"
@.str.3 = [10 x i8] c"xs_double\00"
define i8* @find_gct(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br label %6
6: ; preds = %17, %3
%7 = phi i8* [ %1, %3 ], [ %20, %17 ]
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %6
br i1 %5, label %11, label %22
11: ; preds = %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br label %21
17: ; preds = %6
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
br i1 %5, label %32, label %6
21: ; preds = %11, %21
br i1 %16, label %21, label %22
22: ; preds = %21, %10
%23 = phi i8* [ %2, %10 ], [ %14, %21 ]
%24 = tail call i32 @type2weight(i8* %7)
%25 = tail call i32 @type2weight(i8* %23)
%26 = icmp eq i32 %24, -1
%27 = icmp eq i32 %25, -1
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %32, label %29
29: ; preds = %22
%30 = tail call i32 @maxi(i32 %24, i32 %25)
%31 = tail call i8* @weight2type(i32 %30)
br label %32
32: ; preds = %17, %22, %29
%33 = phi i8* [ %31, %29 ], [ null, %22 ], [ %20, %17 ]
ret i8* %33
}