#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *find_gct(char const *, char const *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ generate_arg(int /*<<< orphan*/ *, char const *,
                                char const *, char *);
int /*<<< orphan*/ strcmp(char const *, char *);
int gfun_cpp(FILE *f, const char *op, const char *ops, const char *type1,
             const char *type2) {
  const char *gct = find_gct(op, type1, type2);
  if (!gct)
    return -1;
  fprintf(f,
          "tuple_cell op_numeric_%s_%s_%s(const tuple_cell &a1, const "
          "tuple_cell &a2)\n{\n",
          op, type1, type2);
  fprintf(f, "    return tuple_cell::atomic(");
  if (!strcmp(op, "divide") || !strcmp(op, "integer_divide") ||
      !strcmp(op, "mod")) {
    fprintf(f, "%s(", ops);
    generate_arg(f, gct, type1, "a1");
    fprintf(f, ", ");
    generate_arg(f, gct, type2, "a2");
    fprintf(f, ")");
  } else if (!strcmp(op, "equal") && !strcmp(type1, "xs_double")) {
    generate_arg(f, gct, type2, "a2");
    fprintf(f, " %s ", ops);
    generate_arg(f, gct, type1, "a1");
  } else {
    generate_arg(f, gct, type1, "a1");
    fprintf(f, " %s ", ops);
    generate_arg(f, gct, type2, "a2");
  }
  fprintf(f, ");\n}\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<gfun_cpp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <find_gct@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1188 <gfun_cpp+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    1353 <gfun_cpp+0x213>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1203 <gfun_cpp+0xc3>
mov    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1203 <gfun_cpp+0xc3>
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1272 <gfun_cpp+0x132>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe58(%rip),%rcx
call   1060 <generate_arg@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe34(%rip),%rcx
call   1060 <generate_arg@plt>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    133a <gfun_cpp+0x1fa>
mov    -0x18(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12ef <gfun_cpp+0x1af>
mov    -0x28(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12ef <gfun_cpp+0x1af>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xdd3(%rip),%rcx
call   1060 <generate_arg@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd9f(%rip),%rcx
call   1060 <generate_arg@plt>
jmp    1335 <gfun_cpp+0x1f5>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd82(%rip),%rcx
call   1060 <generate_arg@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xd5a(%rip),%rcx
call   1060 <generate_arg@plt>
jmp    133a <gfun_cpp+0x1fa>
mov    -0x10(%rbp),%rdi
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfun_cpp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
call   1030 <find_gct@plt>
test   %rax,%rax
je     12ef <gfun_cpp+0x18f>
mov    %rax,%r14
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe99(%rip),%rdi
mov    $0x1e,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xea7(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     126e <gfun_cpp+0x10e>
lea    0xe88(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     126e <gfun_cpp+0x10e>
lea    0xe84(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     126e <gfun_cpp+0x10e>
lea    0xe82(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    122e <gfun_cpp+0xce>
lea    0xe75(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1303 <gfun_cpp+0x1a3>
lea    0xe4f(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <generate_arg@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe2c(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <generate_arg@plt>
jmp    12d2 <gfun_cpp+0x172>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdfb(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <generate_arg@plt>
lea    0xde9(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xdd3(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <generate_arg@plt>
mov    $0x29,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
lea    0xdc9(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
xor    %eax,%eax
jmp    12f4 <gfun_cpp+0x194>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd80(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <generate_arg@plt>
lea    0xd7e(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xd51(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
jmp    1267 <gfun_cpp+0x107>

LLVM IR (-O0):
@.str = [78 x i8] c"tuple_cell op_numeric_%s_%s_%s(const tuple_cell &a1, const tuple_cell &a2)\0A{\0A\00"
@.str.1 = [31 x i8] c" return tuple_cell::atomic(\00"
@.str.2 = [7 x i8] c"divide\00"
@.str.3 = [15 x i8] c"integer_divide\00"
@.str.4 = [4 x i8] c"mod\00"
@.str.5 = [4 x i8] c"%s(\00"
@.str.6 = [3 x i8] c"a1\00"
@.str.7 = [3 x i8] c", \00"
@.str.8 = [3 x i8] c"a2\00"
@.str.9 = [2 x i8] c")\00"
@.str.10 = [6 x i8] c"equal\00"
@.str.11 = [10 x i8] c"xs_double\00"
@.str.12 = [5 x i8] c" %s \00"
@.str.13 = [7 x i8] c");\0A}\0A\0A\00"
define i32 @gfun_cpp(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%13 = load i8*, i8** %8
%14 = load i8*, i8** %10
%15 = load i8*, i8** %11
%16 = call i8* @find_gct(i8* %13, i8* %14, i8* %15)
store i8* %16, i8** %12
%17 = load i8*, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %5
store i32 -1, i32* %6
br label %91
20: ; preds = %5
%21 = load i32*, i32** %7
%22 = load i8*, i8** %8
%23 = load i8*, i8** %10
%24 = load i8*, i8** %11
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i8* %24)
%26 = load i32*, i32** %7
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8*, i8** %8
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %20
%32 = load i8*, i8** %8
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %55, label %39
39: ; preds = %35, %31, %20
%40 = load i32*, i32** %7
%41 = load i8*, i8** %9
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = load i32*, i32** %7
%44 = load i8*, i8** %12
%45 = load i8*, i8** %10
%46 = call i32 @generate_arg(i32* %43, i8* %44, i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%47 = load i32*, i32** %7
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%49 = load i32*, i32** %7
%50 = load i8*, i8** %12
%51 = load i8*, i8** %11
%52 = call i32 @generate_arg(i32* %49, i8* %50, i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%53 = load i32*, i32** %7
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %88
55: ; preds = %35
%56 = load i8*, i8** %8
%57 = call i32 @strcmp(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%58 = icmp ne i32 %57, 0
br i1 %58, label %75, label %59
59: ; preds = %55
%60 = load i8*, i8** %10
%61 = call i32 @strcmp(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %75, label %63
63: ; preds = %59
%64 = load i32*, i32** %7
%65 = load i8*, i8** %12
%66 = load i8*, i8** %11
%67 = call i32 @generate_arg(i32* %64, i8* %65, i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%68 = load i32*, i32** %7
%69 = load i8*, i8** %9
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %69)
%71 = load i32*, i32** %7
%72 = load i8*, i8** %12
%73 = load i8*, i8** %10
%74 = call i32 @generate_arg(i32* %71, i8* %72, i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %87
75: ; preds = %59, %55
%76 = load i32*, i32** %7
%77 = load i8*, i8** %12
%78 = load i8*, i8** %10
%79 = call i32 @generate_arg(i32* %76, i8* %77, i8* %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%80 = load i32*, i32** %7
%81 = load i8*, i8** %9
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %81)
%83 = load i32*, i32** %7
%84 = load i8*, i8** %12
%85 = load i8*, i8** %11
%86 = call i32 @generate_arg(i32* %83, i8* %84, i8* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %87
87: ; preds = %75, %63
br label %88
88: ; preds = %87, %39
%89 = load i32*, i32** %7
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %6
br label %91
91: ; preds = %88, %19
%92 = load i32, i32* %6
ret i32 %92
}

LLVM IR (-O2):
@.str = [78 x i8] c"tuple_cell op_numeric_%s_%s_%s(const tuple_cell &a1, const tuple_cell &a2)\0A{\0A\00"
@.str.1 = [31 x i8] c" return tuple_cell::atomic(\00"
@.str.2 = [7 x i8] c"divide\00"
@.str.3 = [15 x i8] c"integer_divide\00"
@.str.4 = [4 x i8] c"mod\00"
@.str.5 = [4 x i8] c"%s(\00"
@.str.6 = [3 x i8] c"a1\00"
@.str.7 = [3 x i8] c", \00"
@.str.8 = [3 x i8] c"a2\00"
@.str.10 = [6 x i8] c"equal\00"
@.str.11 = [10 x i8] c"xs_double\00"
@.str.12 = [5 x i8] c" %s \00"
@.str.13 = [7 x i8] c");\0A}\0A\0A\00"
define i32 @gfun_cpp(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i8* @find_gct(i8* %1, i8* %3, i8* %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %41, label %8
8: ; preds = %5
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %3, i8* %4)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 30, i64 1, i32* %0)
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16, %13, %8
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%21 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %0)
%23 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%24 = tail call i32 @fputc(i32 41, i32* %0)
br label %39
25: ; preds = %16
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %2)
%34 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %39
35: ; preds = %28, %25
%36 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %2)
%38 = tail call i32 @generate_arg(i32* %0, i8* %6, i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %39
39: ; preds = %31, %35, %19
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %41
41: ; preds = %5, %39
%42 = phi i32 [ 0, %39 ], [ -1, %5 ]
ret i32 %42
}