#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 deutf(char *, int *);
int /*<<< orphan*/ printf(char *, char *, int, int, ...);
void test(char *file, int line, char *s, int ebt, int ecp) {
  int rcp = -1;
  int rbt = deutf(s, &rcp);
  if (rbt != ebt)
    printf("%s:%i: FAIL taken %i != %i expected\n", file, line, rbt, ebt);
  else if (ecp == -1)
    printf("%s:%i: OK taken %i invalid\n", file, line, -rbt);
  else if (rcp != ecp)
    printf("%s:%i: FAIL codepoint 0x%X != 0x%X expected\n", file, line, rcp,
           ecp);
  else
    printf("%s:%i: OK taken %i codepoint 0x%X\n", file, line, rbt, rcp);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <deutf@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     117e <test+0x5e>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <test+0xda>
cmpl   $0xffffffff,-0x20(%rbp)
jne    11a7 <test+0x87>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %ecx,%ecx
sub    -0x28(%rbp),%ecx
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <test+0xd5>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11d4 <test+0xb4>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <test+0xd0>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <test+0xd5>
jmp    11fa <test+0xda>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %esi,%r14d
mov    %rdi,%r15
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x4(%rsp),%rsi
mov    %rdx,%rdi
call   1040 <deutf@plt>
cmp    %ebp,%eax
jne    1169 <test+0x49>
cmp    $0xffffffff,%ebx
je     117d <test+0x5d>
mov    0x4(%rsp),%ecx
cmp    %ebx,%ecx
jne    1197 <test+0x77>
lea    0xf0f(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
jmp    11a4 <test+0x84>
lea    0xe90(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
jmp    11a7 <test+0x87>
neg    %ebp
lea    0xe9f(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11ae <test+0x8e>
lea    0xea3(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"%s:%i: FAIL taken %i != %i expected\0A\00"
@.str.1 = [28 x i8] c"%s:%i: OK taken %i invalid\0A\00"
@.str.2 = [45 x i8] c"%s:%i: FAIL codepoint 0x%X != 0x%X expected\0A\00"
@.str.3 = [35 x i8] c"%s:%i: OK taken %i codepoint 0x%X\0A\00"
define void @test(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 -1, i32* %11
%13 = load i8*, i8** %8
%14 = call i32 @deutf(i8* %13, i32* %11)
store i32 %14, i32* %12
%15 = load i32, i32* %12
%16 = load i32, i32* %9
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %12
%22 = load i32, i32* %9
%23 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20, i32 %21, i32 %22)
br label %51
24: ; preds = %5
%25 = load i32, i32* %10
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %12
%31 = sub nsw i32 0, %30
%32 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %28, i32 %29, i32 %31)
br label %50
33: ; preds = %24
%34 = load i32, i32* %11
%35 = load i32, i32* %10
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = load i32, i32* %7
%40 = load i32, i32* %11
%41 = load i32, i32* %10
%42 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %38, i32 %39, i32 %40, i32 %41)
br label %49
43: ; preds = %33
%44 = load i8*, i8** %6
%45 = load i32, i32* %7
%46 = load i32, i32* %12
%47 = load i32, i32* %11
%48 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %44, i32 %45, i32 %46, i32 %47)
br label %49
49: ; preds = %43, %37
br label %50
50: ; preds = %49, %27
br label %51
51: ; preds = %50, %18
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"%s:%i: FAIL taken %i != %i expected\0A\00"
@.str.1 = [28 x i8] c"%s:%i: OK taken %i invalid\0A\00"
@.str.2 = [45 x i8] c"%s:%i: FAIL codepoint 0x%X != 0x%X expected\0A\00"
@.str.3 = [35 x i8] c"%s:%i: OK taken %i codepoint 0x%X\0A\00"
define void @test(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i32 -1, i32* %6
%8 = call i32 @deutf(i8* %2, i32* %6)
%9 = icmp eq i32 %8, %3
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %8, i32 %3)
br label %24
12: ; preds = %5
%13 = icmp eq i32 %4, -1
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = sub nsw i32 0, %3
%16 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1, i32 %15)
br label %24
17: ; preds = %12
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, %4
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %1, i32 %18, i32 %4)
br label %24
22: ; preds = %17
%23 = call i32 (i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %1, i32 %3, i32 %4)
br label %24
24: ; preds = %14, %22, %20, %10
ret void
}