#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gen_lohi(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ gen_reg_glb_lohi(int /*<<< orphan*/ *, char *, int, int);
void gen_reg_test(FILE *outfile, char *regname, int lohi, int dim) {
  fprintf(outfile, "if ((_");
  if (lohi == 0) {
    fprintf(outfile, "AFTER_BEG");
  } else {
    fprintf(outfile, "BEFOR_END");
  }
  fprintf(outfile, "_OF_REG(_DefaultGrid, %s, %d)) && (", regname, dim);
  gen_lohi(outfile, lohi);
  if (lohi == 0) {
    fprintf(outfile, "<=");
  } else {
    fprintf(outfile, ">=");
  }
  gen_reg_glb_lohi(outfile, regname, (((lohi) == 0) ? 1 : 0), dim);
  fprintf(outfile, ")) {\n");
}


x86 assembly (clang, -O0):
<gen_reg_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1179 <gen_reg_test+0x49>
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    118b <gen_reg_test+0x5b>
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%ecx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <gen_lohi@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11d1 <gen_reg_test+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11e3 <gen_reg_test+0xb3>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmove  %eax,%edx
mov    -0x18(%rbp),%ecx
call   1030 <gen_reg_glb_lohi@plt>
mov    -0x8(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_reg_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
xor    %ebp,%ebp
test   %r12d,%r12d
lea    0xe8b(%rip),%rax
lea    0xe8e(%rip),%rdi
cmove  %rax,%rdi
sete   %bpl
lea    0xead(%rip),%rax
lea    0xea9(%rip),%r13
cmove  %rax,%r13
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe62(%rip),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1060 <gen_lohi@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <gen_reg_glb_lohi@plt>
lea    0xe48(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"if ((_\00"
@.str.1 = [10 x i8] c"AFTER_BEG\00"
@.str.2 = [10 x i8] c"BEFOR_END\00"
@.str.3 = [36 x i8] c"_OF_REG(_DefaultGrid, %s, %d)) && (\00"
@.str.4 = [3 x i8] c"<=\00"
@.str.5 = [3 x i8] c">=\00"
@.str.6 = [6 x i8] c")) {\0A\00"
define void @gen_reg_test(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32*, i32** %5
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32*, i32** %5
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %19
16: ; preds = %4
%17 = load i32*, i32** %5
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16, %13
%20 = load i32*, i32** %5
%21 = load i8*, i8** %6
%22 = load i32, i32* %8
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %21, i32 %22)
%24 = load i32*, i32** %5
%25 = load i32, i32* %7
%26 = call i32 @gen_lohi(i32* %24, i32 %25)
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load i32*, i32** %5
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %35
32: ; preds = %19
%33 = load i32*, i32** %5
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %32, %29
%36 = load i32*, i32** %5
%37 = load i8*, i8** %6
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 1, i32 0
%42 = load i32, i32* %8
%43 = call i32 @gen_reg_glb_lohi(i32* %36, i8* %37, i32 %41, i32 %42)
%44 = load i32*, i32** %5
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"if ((_\00"
@.str.1 = [10 x i8] c"AFTER_BEG\00"
@.str.2 = [10 x i8] c"BEFOR_END\00"
@.str.3 = [36 x i8] c"_OF_REG(_DefaultGrid, %s, %d)) && (\00"
@.str.4 = [3 x i8] c"<=\00"
@.str.5 = [3 x i8] c">=\00"
@.str.6 = [6 x i8] c")) {\0A\00"
define void @gen_reg_test(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6, i64 1, i32* %0)
%6 = icmp eq i32 %2, 0
%7 = select i1 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i64 @fwrite(i8* %7, i64 9, i64 1, i32* %0)
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %3)
%10 = tail call i32 @gen_lohi(i32* %0, i32 %2)
%11 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%12 = tail call i64 @fwrite(i8* %11, i64 2, i64 1, i32* %0)
%13 = zext i1 %6 to i32
%14 = tail call i32 @gen_reg_glb_lohi(i32* %0, i8* %1, i32 %13, i32 %3)
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 5, i64 1, i32* %0)
ret void
}