#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 */
struct triple **triple_rhs(struct compile_state *, struct triple *,
                           struct triple **);
int /*<<< orphan*/ unuse_triple(struct triple *, struct triple *);
void unuse_rhs(struct compile_state *state, struct triple *ins) {
  struct triple **expr;
  expr = triple_rhs(state, ins, 0);
  for (; expr; expr = triple_rhs(state, ins, expr)) {
    if (*expr) {
      unuse_triple(*expr, ins);
      *expr = 0;
    }
  }
}


x86 assembly (clang, -O0):
<unuse_rhs>:
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_rhs@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1198 <unuse_rhs+0x78>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1179 <unuse_rhs+0x59>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <unuse_triple@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    117e <unuse_rhs+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <triple_rhs@plt>
mov    %rax,-0x18(%rbp)
jmp    1145 <unuse_rhs+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unuse_rhs>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %edx,%edx
call   1040 <triple_rhs@plt>
test   %rax,%rax
je     116f <unuse_rhs+0x4f>
mov    %rax,%rbx
jmp    1156 <unuse_rhs+0x36>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <triple_rhs@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116f <unuse_rhs+0x4f>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1140 <unuse_rhs+0x20>
mov    %r15,%rsi
call   1030 <unuse_triple@plt>
movq   $0x0,(%rbx)
jmp    1140 <unuse_rhs+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
define void @unuse_rhs(%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_rhs(%struct.compile_state* %6, %struct.triple* %7, %struct.triple** null)
store %struct.triple** %8, %struct.triple*** %5
br label %9
9: ; preds = %23, %2
%10 = load %struct.triple**, %struct.triple*** %5
%11 = icmp ne %struct.triple** %10, null
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load %struct.triple**, %struct.triple*** %5
%14 = load %struct.triple*, %struct.triple** %13
%15 = icmp ne %struct.triple* %14, null
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load %struct.triple**, %struct.triple*** %5
%18 = load %struct.triple*, %struct.triple** %17
%19 = load %struct.triple*, %struct.triple** %4
%20 = call i32 @unuse_triple(%struct.triple* %18, %struct.triple* %19)
%21 = load %struct.triple**, %struct.triple*** %5
store %struct.triple* null, %struct.triple** %21
br label %22
22: ; preds = %16, %12
br label %23
23: ; preds = %22
%24 = load %struct.compile_state*, %struct.compile_state** %3
%25 = load %struct.triple*, %struct.triple** %4
%26 = load %struct.triple**, %struct.triple*** %5
%27 = call %struct.triple** @triple_rhs(%struct.compile_state* %24, %struct.triple* %25, %struct.triple** %26)
store %struct.triple** %27, %struct.triple*** %5
br label %9
28: ; preds = %9
ret void
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
define void @unuse_rhs(%struct.compile_state* %0, %struct.triple* %1) {
%3 = tail call %struct.triple** @triple_rhs(%struct.compile_state* %0, %struct.triple* %1, %struct.triple** null)
%4 = icmp eq %struct.triple** %3, null
br i1 %4, label %14, label %5
5: ; preds = %2, %11
%6 = phi %struct.triple** [ %12, %11 ], [ %3, %2 ]
%7 = load %struct.triple*, %struct.triple** %6
%8 = icmp eq %struct.triple* %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @unuse_triple(%struct.triple* %7, %struct.triple* %1)
store %struct.triple* null, %struct.triple** %6
br label %11
11: ; preds = %5, %9
%12 = tail call %struct.triple** @triple_rhs(%struct.compile_state* %0, %struct.triple* %1, %struct.triple** %6)
%13 = icmp eq %struct.triple** %12, null
br i1 %13, label %14, label %5
14: ; preds = %11, %2
ret void
}