#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 *, struct triple *,
                                  char *);
struct triple **triple_targ(struct compile_state *, struct triple *,
                            struct triple **);
void check_targ(struct compile_state *state, struct triple *ins) {
  struct triple **expr;
  expr = triple_targ(state, ins, 0);
  for (; expr; expr = triple_targ(state, ins, expr)) {
    internal_error(state, ins, "unexpected targ");
  }
}


x86 assembly (clang, -O0):
<check_targ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <triple_targ@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117e <check_targ+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xea1(%rip),%rdx
call   1030 <internal_error@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <triple_targ@plt>
mov    %rax,-0x18(%rbp)
jmp    1145 <check_targ+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_targ>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edx,%edx
call   1040 <triple_targ@plt>
test   %rax,%rax
je     1174 <check_targ+0x54>
mov    %rax,%rbx
lea    0xebc(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <internal_error@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <triple_targ@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1150 <check_targ+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [16 x i8] c"unexpected targ\00"
define void @check_targ(%struct.compile_state* %0, %struct.triple* %1) {
%3 = alloca %struct.compile_state*
%4 = alloca %struct.triple*
%5 = alloca %struct.triple**
store %struct.compile_state* %0, %struct.compile_state** %3
store %struct.triple* %1, %struct.triple** %4
%6 = load %struct.compile_state*, %struct.compile_state** %3
%7 = load %struct.triple*, %struct.triple** %4
%8 = call %struct.triple** @triple_targ(%struct.compile_state* %6, %struct.triple* %7, %struct.triple** null)
store %struct.triple** %8, %struct.triple*** %5
br label %9
9: ; preds = %16, %2
%10 = load %struct.triple**, %struct.triple*** %5
%11 = icmp ne %struct.triple** %10, null
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load %struct.compile_state*, %struct.compile_state** %3
%14 = load %struct.triple*, %struct.triple** %4
%15 = call i32 @internal_error(%struct.compile_state* %13, %struct.triple* %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %12
%17 = load %struct.compile_state*, %struct.compile_state** %3
%18 = load %struct.triple*, %struct.triple** %4
%19 = load %struct.triple**, %struct.triple*** %5
%20 = call %struct.triple** @triple_targ(%struct.compile_state* %17, %struct.triple* %18, %struct.triple** %19)
store %struct.triple** %20, %struct.triple*** %5
br label %9
21: ; preds = %9
ret void
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [16 x i8] c"unexpected targ\00"
define void @check_targ(%struct.compile_state* %0, %struct.triple* %1) {
%3 = tail call %struct.triple** @triple_targ(%struct.compile_state* %0, %struct.triple* %1, %struct.triple** null)
%4 = icmp eq %struct.triple** %3, null
br i1 %4, label %10, label %5
5: ; preds = %2, %5
%6 = phi %struct.triple** [ %8, %5 ], [ %3, %2 ]
%7 = tail call i32 @internal_error(%struct.compile_state* %0, %struct.triple* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = tail call %struct.triple** @triple_targ(%struct.compile_state* %0, %struct.triple* %1, %struct.triple** %6)
%9 = icmp eq %struct.triple** %8, null
br i1 %9, label %10, label %5
10: ; preds = %5, %2
ret void
}