#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*/ sprintf(char *, char *, int, double);
int sscanf(char *, char *, int *, double *);
scalar_t__ strcmp(char *, char *);
int test_3(void) {
  char *str = "10 4.53";
  char buf[64];
  double d;
  int i;
  if (sscanf(str, "%d %lf", &i, &d) != 2) {
    printf("ERROR: sscanf didn't parse input string correctly\n");
    return (-1);
  }
  sprintf(buf, "%d %2.2lf", i, d);
  if (strcmp(buf, str)) {
    printf("ERROR: sscanf()/sprintf() didn't parse unparse correctly\n");
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<test_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
lea    -0x5c(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     118c <test_3+0x4c>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <test_3+0x9a>
lea    -0x50(%rbp),%rdi
mov    -0x5c(%rbp),%edx
movsd  -0x58(%rbp),%xmm0
lea    0xea3(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11d3 <test_3+0x93>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <test_3+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_3>:
push   %rbx
sub    $0x50,%rsp
lea    0xeb4(%rip),%rdi
lea    0xeb5(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11a2 <test_3+0x62>
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
lea    0xe97(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b5 <test_3+0x75>
lea    0xe79(%rip),%rdi
jmp    11a9 <test_3+0x69>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    11b7 <test_3+0x77>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"10 4.53\00"
@.str.1 = [7 x i8] c"%d %lf\00"
@.str.2 = [51 x i8] c"ERROR: sscanf didn't parse input string correctly\0A\00"
@.str.3 = [10 x i8] c"%d %2.2lf\00"
@.str.4 = [58 x i8] c"ERROR: sscanf()/sprintf() didn't parse unparse correctly\0A\00"
define i32 @test_3() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [64 x i8]
%4 = alloca double
%5 = alloca i32
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %5, double* %4)
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %23
11: ; preds = %0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* %5
%14 = load double, double* %4
%15 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %13, double %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i64 @strcmp(i8* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %23
22: ; preds = %11
store i32 0, i32* %1
br label %23
23: ; preds = %22, %20, %9
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"10 4.53\00"
@.str.1 = [7 x i8] c"%d %lf\00"
@.str.3 = [10 x i8] c"%d %2.2lf\00"
@str = [57 x i8] c"ERROR: sscanf()/sprintf() didn't parse unparse correctly\00"
@str.5 = [50 x i8] c"ERROR: sscanf didn't parse input string correctly\00"
define i32 @test_3() {
%1 = alloca [64 x i8]
%2 = alloca double
%3 = alloca i32
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%5 = bitcast double* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, double* %2)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i32, i32* %3
%11 = load double, double* %2
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %10, double %11)
%13 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9, %0
%16 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @str.5, i64 0, i64 0), %0 ], [ getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0), %9 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
br label %18
18: ; preds = %15, %9
%19 = phi i32 [ 0, %9 ], [ -1, %15 ]
ret i32 %19
}