#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 /*<<< orphan*/ Fail(char *, int, int, int);
int printf(char *, int, void *);
int strlen(char *);
void DoArgumentPrecTest(char *formatstr, int precision, void *param,
                        char *paramstr, char *checkstr1, char *checkstr2) {
  int ret;
  ret = printf(formatstr, precision, param);
  if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) {
    Fail("Expected printf to return %d or %d, got %d.\n", strlen(checkstr1),
         strlen(checkstr2), ret);
  }
}


x86 assembly (clang, -O0):
<DoArgumentPrecTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <printf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
je     11c3 <DoArgumentPrecTest+0x93>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
je     11c3 <DoArgumentPrecTest+0x93>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%esi
mov    %eax,%edx
mov    -0x34(%rbp),%ecx
lea    0xe42(%rip),%rdi
call   1050 <Fail@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoArgumentPrecTest>:
push   %rbp
push   %r14
push   %rbx
mov    %r9,%r14
mov    %r8,%rbx
call   1040 <printf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
je     1159 <DoArgumentPrecTest+0x29>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jne    115e <DoArgumentPrecTest+0x2e>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xe89(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
mov    %ebp,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <Fail@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Expected printf to return %d or %d, got %d.\0A\00"
define void @DoArgumentPrecTest(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %9
%17 = call i32 @printf(i8* %14, i32 %15, i8* %16)
store i32 %17, i32* %13
%18 = load i32, i32* %13
%19 = load i8*, i8** %11
%20 = call i32 @strlen(i8* %19)
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %34
22: ; preds = %6
%23 = load i32, i32* %13
%24 = load i8*, i8** %12
%25 = call i32 @strlen(i8* %24)
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = load i8*, i8** %11
%29 = call i32 @strlen(i8* %28)
%30 = load i8*, i8** %12
%31 = call i32 @strlen(i8* %30)
%32 = load i32, i32* %13
%33 = call i32 @Fail(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %31, i32 %32)
br label %34
34: ; preds = %27, %22, %6
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"Expected printf to return %d or %d, got %d.\0A\00"
define void @DoArgumentPrecTest(i8* %0, i32 %1, i8* %2, i8* nocapture readnone %3, i8* %4, i8* %5) {
%7 = tail call i32 @printf(i8* %0, i32 %1, i8* %2)
%8 = tail call i32 @strlen(i8* %4)
%9 = icmp eq i32 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = tail call i32 @strlen(i8* %5)
%12 = icmp eq i32 %7, %11
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @strlen(i8* %4)
%15 = tail call i32 @strlen(i8* %5)
%16 = tail call i32 @Fail(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %7)
br label %17
17: ; preds = %13, %10, %6
ret void
}