#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 triple {
  int dummy;
};
struct compile_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ internal_error(struct compile_state *, int /*<<< orphan*/,
                                  char *);
int /*<<< orphan*/ is_const(struct triple *);
int /*<<< orphan*/ is_zero(struct triple *);
int const_ltrue(struct compile_state *state, struct triple *ins,
                struct triple *rhs) {
  if (!is_const(rhs)) {
    internal_error(state, 0, "non const passed to const_true");
  }
  return !is_zero(rhs);
}


x86 assembly (clang, -O0):
<const_ltrue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <is_const@plt>
cmp    $0x0,%eax
jne    1168 <const_ltrue+0x38>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
lea    0xe9d(%rip),%rdx
call   1030 <internal_error@plt>
mov    -0x18(%rbp),%rdi
call   1050 <is_zero@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<const_ltrue>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <is_const@plt>
test   %eax,%eax
jne    1157 <const_ltrue+0x27>
lea    0xeb3(%rip),%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <internal_error@plt>
mov    %rbx,%rdi
call   1050 <is_zero@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [31 x i8] c"non const passed to const_true\00"
define i32 @const_ltrue(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2) {
%4 = alloca %struct.compile_state*
%5 = alloca %struct.triple*
%6 = alloca %struct.triple*
store %struct.compile_state* %0, %struct.compile_state** %4
store %struct.triple* %1, %struct.triple** %5
store %struct.triple* %2, %struct.triple** %6
%7 = load %struct.triple*, %struct.triple** %6
%8 = call i32 @is_const(%struct.triple* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load %struct.compile_state*, %struct.compile_state** %4
%12 = call i32 @internal_error(%struct.compile_state* %11, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %3
%14 = load %struct.triple*, %struct.triple** %6
%15 = call i32 @is_zero(%struct.triple* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
ret i32 %18
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [31 x i8] c"non const passed to const_true\00"
define i32 @const_ltrue(%struct.compile_state* %0, %struct.triple* nocapture readnone %1, %struct.triple* %2) {
%4 = tail call i32 @is_const(%struct.triple* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @internal_error(%struct.compile_state* %0, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @is_zero(%struct.triple* %2)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
ret i32 %11
}