#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 asprintf(char **, char *, float, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int test_asprintf(void) {
  char *out = NULL;
  int r;
  r = asprintf(&out, "%d", 0);
  do {
    if (!(r == 1)) {
      printf("expression '%s' untrue at %d\n", "r == 1", 144);
      return 0;
    }
  } while (0);
  do {
    if (!(!strcmp("0", out))) {
      printf("expression '%s' untrue at %d\n", "!strcmp(\"0\", out)", 145);
      return 0;
    }
  } while (0);
  free(out);
  r = asprintf(&out, "%c%c%cbar", 'f', 'o', 'o');
  do {
    if (!(r == 6)) {
      printf("expression '%s' untrue at %d\n", "r == 6", 149);
      return 0;
    }
  } while (0);
  do {
    if (!(!strcmp("foobar", out))) {
      printf("expression '%s' untrue at %d\n", "!strcmp(\"foobar\", out)", 150);
      return 0;
    }
  } while (0);
  free(out);
  return 1;
}


x86 assembly (clang, -O0):
<test_asprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1196 <test_asprintf+0x56>
lea    0xe8e(%rip),%rdi
lea    0xea5(%rip),%rsi
mov    $0x90,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1299 <test_asprintf+0x159>
jmp    119b <test_asprintf+0x5b>
jmp    11a0 <test_asprintf+0x60>
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11dd <test_asprintf+0x9d>
lea    0xe47(%rip),%rdi
lea    0xe67(%rip),%rsi
mov    $0x91,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1299 <test_asprintf+0x159>
jmp    11e2 <test_asprintf+0xa2>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
movss  0xe02(%rip),%xmm0
mov    $0x6f,%ecx
mov    %ecx,%edx
mov    $0x1,%al
call   1060 <asprintf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
je     123d <test_asprintf+0xfd>
lea    0xde7(%rip),%rdi
lea    0xe23(%rip),%rsi
mov    $0x95,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1299 <test_asprintf+0x159>
jmp    1242 <test_asprintf+0x102>
jmp    1247 <test_asprintf+0x107>
mov    -0x10(%rbp),%rsi
lea    0xdff(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     1284 <test_asprintf+0x144>
lea    0xda0(%rip),%rdi
lea    0xdea(%rip),%rsi
mov    $0x96,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1299 <test_asprintf+0x159>
jmp    1289 <test_asprintf+0x149>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_asprintf>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeaf(%rip),%rsi
lea    0x8(%rsp),%rdi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1060 <asprintf@plt>
cmp    $0x1,%eax
jne    1196 <test_asprintf+0x56>
mov    0x8(%rsp),%rbx
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11b6 <test_asprintf+0x76>
lea    0xe7f(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x91,%edx
jmp    11a9 <test_asprintf+0x69>
lea    0xe6a(%rip),%rdi
lea    0xe81(%rip),%rsi
mov    $0x90,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe7b(%rip),%rsi
lea    0x8(%rsp),%rdi
movss  0xe2e(%rip),%xmm0
mov    $0x6f,%edx
mov    $0x6f,%ecx
mov    $0x1,%al
call   1060 <asprintf@plt>
cmp    $0x6,%eax
jne    1215 <test_asprintf+0xd5>
mov    0x8(%rsp),%rbx
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     122d <test_asprintf+0xed>
lea    0xe00(%rip),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x96,%edx
jmp    11a9 <test_asprintf+0x69>
lea    0xdeb(%rip),%rdi
lea    0xe27(%rip),%rsi
mov    $0x95,%edx
jmp    11a9 <test_asprintf+0x69>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
jmp    11b0 <test_asprintf+0x70>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [7 x i8] c"r == 1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [18 x i8] c"!strcmp(\220\22, out)\00"
@.str.5 = [10 x i8] c"%c%c%cbar\00"
@.str.6 = [7 x i8] c"r == 6\00"
@.str.7 = [7 x i8] c"foobar\00"
@.str.8 = [23 x i8] c"!strcmp(\22foobar\22, out)\00"
define i32 @test_asprintf() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i8* null, i8** %2
%4 = call i32 (i8**, i8*, float, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float 0.000000e+00)
store i32 %4, i32* %3
br label %5
5: ; preds = %0
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 144)
store i32 0, i32* %1
br label %40
10: ; preds = %5
br label %11
11: ; preds = %10
br label %12
12: ; preds = %11
%13 = load i8*, i8** %2
%14 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 145)
store i32 0, i32* %1
br label %40
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
%22 = call i32 (i8**, i8*, float, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), float 1.020000e+02, i32 111, i32 111)
store i32 %22, i32* %3
br label %23
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 6
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 149)
store i32 0, i32* %1
br label %40
28: ; preds = %23
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i8*, i8** %2
%32 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 150)
store i32 0, i32* %1
br label %40
36: ; preds = %30
br label %37
37: ; preds = %36
%38 = load i8*, i8** %2
%39 = call i32 @free(i8* %38)
store i32 1, i32* %1
br label %40
40: ; preds = %37, %34, %26, %16, %8
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [7 x i8] c"r == 1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [18 x i8] c"!strcmp(\220\22, out)\00"
@.str.5 = [10 x i8] c"%c%c%cbar\00"
@.str.6 = [7 x i8] c"r == 6\00"
@.str.7 = [7 x i8] c"foobar\00"
@.str.8 = [23 x i8] c"!strcmp(\22foobar\22, out)\00"
define i32 @test_asprintf() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = call i32 (i8**, i8*, float, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float 0.000000e+00)
%4 = icmp eq i32 %3, 1
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 144)
br label %27
7: ; preds = %0
%8 = load i8*, i8** %1
%9 = call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 145)
br label %27
13: ; preds = %7
%14 = call i32 @free(i8* %8)
%15 = call i32 (i8**, i8*, float, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), float 1.020000e+02, i32 111, i32 111)
%16 = icmp eq i32 %15, 6
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 149)
br label %27
19: ; preds = %13
%20 = load i8*, i8** %1
%21 = call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(1) %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 150)
br label %27
25: ; preds = %19
%26 = call i32 @free(i8* %20)
br label %27
27: ; preds = %25, %23, %17, %11, %5
%28 = phi i32 [ 0, %11 ], [ 0, %23 ], [ 1, %25 ], [ 0, %17 ], [ 0, %5 ]
ret i32 %28
}