#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*/ printf(char *);
int /*<<< orphan*/ test_asprintf();
int /*<<< orphan*/ test_snprintf();
int /*<<< orphan*/ test_sprintf();
int /*<<< orphan*/ test_sscanf();
int main(int argc, char **argv) {
  if (!test_sprintf())
    return 1;
  if (!test_asprintf())
    return 1;
  if (!test_snprintf())
    return 1;
  if (!test_sscanf())
    return 1;
  printf("OK\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <test_sprintf@plt>
cmp    $0x0,%eax
jne    1182 <main+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
mov    $0x0,%al
call   1070 <test_asprintf@plt>
cmp    $0x0,%eax
jne    119e <main+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
mov    $0x0,%al
call   1050 <test_snprintf@plt>
cmp    $0x0,%eax
jne    11ba <main+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
mov    $0x0,%al
call   1040 <test_sscanf@plt>
cmp    $0x0,%eax
jne    11d6 <main+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <test_sprintf@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     1190 <main+0x40>
xor    %eax,%eax
call   1070 <test_asprintf@plt>
test   %eax,%eax
je     1190 <main+0x40>
xor    %eax,%eax
call   1050 <test_snprintf@plt>
test   %eax,%eax
je     1190 <main+0x40>
xor    %eax,%eax
call   1040 <test_sscanf@plt>
test   %eax,%eax
je     1190 <main+0x40>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @test_sprintf()
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 1, i32* %3
br label %23
9: ; preds = %2
%10 = call i32 (...) @test_asprintf()
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9
store i32 1, i32* %3
br label %23
13: ; preds = %9
%14 = call i32 (...) @test_snprintf()
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
store i32 1, i32* %3
br label %23
17: ; preds = %13
%18 = call i32 (...) @test_sscanf()
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %17
store i32 1, i32* %3
br label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %23
23: ; preds = %21, %20, %16, %12, %8
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@str = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @test_sprintf()
%4 = icmp eq i32 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = tail call i32 (...) @test_asprintf()
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %5
%9 = tail call i32 (...) @test_snprintf()
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i32 (...) @test_sscanf()
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %11, %8, %5, %2, %14
%17 = phi i32 [ 0, %14 ], [ 1, %2 ], [ 1, %5 ], [ 1, %8 ], [ 1, %11 ]
ret i32 %17
}