#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 *);
int replace_lhs_use(struct compile_state *, struct triple *, struct triple *,
                    struct triple *);
int replace_misc_use(struct compile_state *, struct triple *, struct triple *,
                     struct triple *);
int replace_rhs_use(struct compile_state *, struct triple *, struct triple *,
                    struct triple *);
int replace_targ_use(struct compile_state *, struct triple *, struct triple *,
                     struct triple *);
void replace_use(struct compile_state *state, struct triple *orig,
                 struct triple *new, struct triple *use) {
  int found;
  found = 0;
  found |= replace_rhs_use(state, orig, new, use);
  found |= replace_lhs_use(state, orig, new, use);
  found |= replace_misc_use(state, orig, new, use);
  found |= replace_targ_use(state, orig, new, use);
  if (!found) {
    internal_error(state, use, "use without use");
  }
}


x86 assembly (clang, -O0):
<replace_use>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <replace_rhs_use@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <replace_lhs_use@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <replace_misc_use@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <replace_targ_use@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11f9 <replace_use+0xa9>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xe0c(%rip),%rdx
call   1060 <internal_error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replace_use>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r15
call   1070 <replace_rhs_use@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1030 <replace_lhs_use@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1040 <replace_misc_use@plt>
mov    %eax,%ebx
or     %ebp,%ebx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1050 <replace_targ_use@plt>
or     %ebx,%eax
je     11bc <replace_use+0x6c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3d(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <internal_error@plt>

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [16 x i8] c"use without use\00"
define void @replace_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3) {
%5 = alloca %struct.compile_state*
%6 = alloca %struct.triple*
%7 = alloca %struct.triple*
%8 = alloca %struct.triple*
%9 = alloca i32
store %struct.compile_state* %0, %struct.compile_state** %5
store %struct.triple* %1, %struct.triple** %6
store %struct.triple* %2, %struct.triple** %7
store %struct.triple* %3, %struct.triple** %8
store i32 0, i32* %9
%10 = load %struct.compile_state*, %struct.compile_state** %5
%11 = load %struct.triple*, %struct.triple** %6
%12 = load %struct.triple*, %struct.triple** %7
%13 = load %struct.triple*, %struct.triple** %8
%14 = call i32 @replace_rhs_use(%struct.compile_state* %10, %struct.triple* %11, %struct.triple* %12, %struct.triple* %13)
%15 = load i32, i32* %9
%16 = or i32 %15, %14
store i32 %16, i32* %9
%17 = load %struct.compile_state*, %struct.compile_state** %5
%18 = load %struct.triple*, %struct.triple** %6
%19 = load %struct.triple*, %struct.triple** %7
%20 = load %struct.triple*, %struct.triple** %8
%21 = call i32 @replace_lhs_use(%struct.compile_state* %17, %struct.triple* %18, %struct.triple* %19, %struct.triple* %20)
%22 = load i32, i32* %9
%23 = or i32 %22, %21
store i32 %23, i32* %9
%24 = load %struct.compile_state*, %struct.compile_state** %5
%25 = load %struct.triple*, %struct.triple** %6
%26 = load %struct.triple*, %struct.triple** %7
%27 = load %struct.triple*, %struct.triple** %8
%28 = call i32 @replace_misc_use(%struct.compile_state* %24, %struct.triple* %25, %struct.triple* %26, %struct.triple* %27)
%29 = load i32, i32* %9
%30 = or i32 %29, %28
store i32 %30, i32* %9
%31 = load %struct.compile_state*, %struct.compile_state** %5
%32 = load %struct.triple*, %struct.triple** %6
%33 = load %struct.triple*, %struct.triple** %7
%34 = load %struct.triple*, %struct.triple** %8
%35 = call i32 @replace_targ_use(%struct.compile_state* %31, %struct.triple* %32, %struct.triple* %33, %struct.triple* %34)
%36 = load i32, i32* %9
%37 = or i32 %36, %35
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %4
%41 = load %struct.compile_state*, %struct.compile_state** %5
%42 = load %struct.triple*, %struct.triple** %8
%43 = call i32 @internal_error(%struct.compile_state* %41, %struct.triple* %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %40, %4
ret void
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [16 x i8] c"use without use\00"
define void @replace_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3) {
%5 = tail call i32 @replace_rhs_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3)
%6 = tail call i32 @replace_lhs_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3)
%7 = or i32 %6, %5
%8 = tail call i32 @replace_misc_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3)
%9 = or i32 %7, %8
%10 = tail call i32 @replace_targ_use(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2, %struct.triple* %3)
%11 = or i32 %9, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = tail call i32 @internal_error(%struct.compile_state* %0, %struct.triple* %3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
ret void
}