#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 */

/* Variables and functions */
int coproc_read(unsigned int volatile *);
int /*<<< orphan*/ coproc_reset(unsigned int volatile *);
int /*<<< orphan*/ coproc_write(unsigned int volatile *, int);
int /*<<< orphan*/ my_printf(char *, int);
int /*<<< orphan*/ my_printfh(char *, unsigned int volatile *, int);
void test_coproc(unsigned int *_adr, int value) {
  volatile unsigned int *adr = (volatile unsigned int *)_adr;
  my_printfh("Testing coprocessor : ", adr, value);
  coproc_reset(adr);
  coproc_write(adr + 1, value);
  int res = coproc_read(adr + 1);
  my_printf(" + result  = ", res);
}


x86 assembly (clang, -O0):
<test_coproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe8b(%rip),%rdi
call   1030 <my_printfh@plt>
mov    -0x18(%rbp),%rdi
call   1060 <coproc_reset@plt>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
mov    -0xc(%rbp),%esi
call   1070 <coproc_write@plt>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1050 <coproc_read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1040 <my_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_coproc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <my_printfh@plt>
mov    %rbx,%rdi
call   1060 <coproc_reset@plt>
add    $0x4,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <coproc_write@plt>
mov    %rbx,%rdi
call   1050 <coproc_read@plt>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <my_printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Testing coprocessor : \00"
@.str.1 = [14 x i8] c" + result = \00"
define void @test_coproc(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = load i32, i32* %4
%10 = call i32 @my_printfh(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32* %8, i32 %9)
%11 = load i32*, i32** %5
%12 = call i32 @coproc_reset(i32* %11)
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %4
%16 = call i32 @coproc_write(i32* %14, i32 %15)
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = call i32 @coproc_read(i32* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call i32 @my_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %20)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Testing coprocessor : \00"
@.str.1 = [14 x i8] c" + result = \00"
define void @test_coproc(i32* %0, i32 %1) {
%3 = tail call i32 @my_printfh(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32* %0, i32 %1)
%4 = tail call i32 @coproc_reset(i32* %0)
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = tail call i32 @coproc_write(i32* %5, i32 %1)
%7 = tail call i32 @coproc_read(i32* %5)
%8 = tail call i32 @my_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret void
}