#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*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ unit_test_int(char *, int, int);
int /*<<< orphan*/ unit_test_str(char *, char *, char *);
void test_sscanf() {
  int i;
  unsigned long long j;
  sscanf("7", "%d", &i);
  unit_test_int("sscanf (unique) nombre entier positif", 7, i);
  sscanf("-42", "%d", &i);
  unit_test_int("sscanf (unique) nombre entier négatif", -42, i);
  sscanf("132423421234", "%llu", &j);
  unit_test_int("sscanf (unique) nombre entier positif long long", 132423421234,
                j);
  char *in = "Hello u 1024 132542151 13403482082 -42";
  char buf[80];
  char l;
  int k;
  unsigned long m;
  sscanf(in, "%s %c %d %lu %llu %d", buf, &l, &i, &m, &j, &k);
  unit_test_str("sscanf (multiple) string", "Hello", buf);
  unit_test_int("sscanf (multiple) caractere", 'u', l);
  unit_test_int("sscanf (multiple) nombre entier signé", 1024, i);
  unit_test_int("sscanf (multiple) nombre entier long long non signé",
                132542151, m);
  unit_test_int("sscanf (multiple) nombre entier long non signé", 13403482082,
                j);
  unit_test_int("sscanf (multiple) nombre entier négatif", -42, k);
}


x86 assembly (clang, -O0):
<test_sscanf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xebe(%rip),%rdi
lea    0xf81(%rip),%rsi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x4(%rbp),%edx
lea    0xea4(%rip),%rdi
mov    $0x7,%esi
call   1030 <unit_test_int@plt>
lea    0xf45(%rip),%rdi
lea    0xf54(%rip),%rsi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x4(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0xffffffd6,%esi
call   1030 <unit_test_int@plt>
lea    0xeb3(%rip),%rdi
lea    0xeb9(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xea6(%rip),%rdi
mov    $0xd50d0d32,%esi
call   1030 <unit_test_int@plt>
lea    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xed9(%rip),%rsi
lea    -0x71(%rbp),%rcx
lea    -0x4(%rbp),%r8
lea    -0x80(%rbp),%r9
lea    -0x10(%rbp),%r10
lea    -0x78(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <sscanf@plt>
lea    -0x70(%rbp),%rdx
lea    0xebf(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1050 <unit_test_str@plt>
movsbl -0x71(%rbp),%edx
lea    0xec7(%rip),%rdi
mov    $0x75,%esi
call   1030 <unit_test_int@plt>
mov    -0x4(%rbp),%edx
lea    0xecf(%rip),%rdi
mov    $0x400,%esi
call   1030 <unit_test_int@plt>
mov    -0x80(%rbp),%rax
mov    %eax,%edx
lea    0xedf(%rip),%rdi
mov    $0x7e66ec7,%esi
call   1030 <unit_test_int@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xefd(%rip),%rdi
mov    $0x1ee8e7e2,%esi
call   1030 <unit_test_int@plt>
mov    -0x78(%rbp),%edx
lea    0xf19(%rip),%rdi
mov    $0xffffffd6,%esi
call   1030 <unit_test_int@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sscanf>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xec0(%rip),%rdi
lea    0xf83(%rip),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%edx
lea    0xe9e(%rip),%rdi
mov    $0x7,%esi
call   1030 <unit_test_int@plt>
lea    0xf3f(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%edx
lea    0xe9b(%rip),%rdi
mov    $0xffffffd6,%esi
call   1030 <unit_test_int@plt>
lea    0xeb1(%rip),%rdi
lea    0xeb7(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x10(%rsp),%edx
lea    0xea2(%rip),%rdi
mov    $0xd50d0d32,%esi
call   1030 <unit_test_int@plt>
lea    0xc(%rsp),%r10
lea    0xebc(%rip),%rdi
lea    0xedc(%rip),%rsi
lea    0x20(%rsp),%rbx
lea    0x7(%rsp),%rcx
lea    0x18(%rsp),%r9
mov    %rbx,%rdx
mov    %r14,%r8
xor    %eax,%eax
push   %r10
push   %r15
call   1040 <sscanf@plt>
add    $0x10,%rsp
lea    0xec6(%rip),%rdi
lea    0xed8(%rip),%rsi
mov    %rbx,%rdx
call   1050 <unit_test_str@plt>
movsbl 0x7(%rsp),%edx
lea    0xeca(%rip),%rdi
mov    $0x75,%esi
call   1030 <unit_test_int@plt>
mov    0x8(%rsp),%edx
lea    0xed1(%rip),%rdi
mov    $0x400,%esi
call   1030 <unit_test_int@plt>
mov    0x18(%rsp),%edx
lea    0xee3(%rip),%rdi
mov    $0x7e66ec7,%esi
call   1030 <unit_test_int@plt>
mov    0x10(%rsp),%edx
lea    0xf03(%rip),%rdi
mov    $0x1ee8e7e2,%esi
call   1030 <unit_test_int@plt>
mov    0xc(%rsp),%edx
lea    0xf1e(%rip),%rdi
mov    $0xffffffd6,%esi
call   1030 <unit_test_int@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"7\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"sscanf (unique) nombre entier positif\00"
@.str.3 = [4 x i8] c"-42\00"
@.str.4 = [39 x i8] c"sscanf (unique) nombre entier n\C3\A9gatif\00"
@.str.5 = [13 x i8] c"132423421234\00"
@.str.6 = [5 x i8] c"%llu\00"
@.str.7 = [48 x i8] c"sscanf (unique) nombre entier positif long long\00"
@.str.8 = [39 x i8] c"Hello u 1024 132542151 13403482082 -42\00"
@.str.9 = [21 x i8] c"%s %c %d %lu %llu %d\00"
@.str.10 = [25 x i8] c"sscanf (multiple) string\00"
@.str.11 = [6 x i8] c"Hello\00"
@.str.12 = [28 x i8] c"sscanf (multiple) caractere\00"
@.str.13 = [39 x i8] c"sscanf (multiple) nombre entier sign\C3\A9\00"
@.str.14 = [53 x i8] c"sscanf (multiple) nombre entier long long non sign\C3\A9\00"
@.str.15 = [48 x i8] c"sscanf (multiple) nombre entier long non sign\C3\A9\00"
@.str.16 = [41 x i8] c"sscanf (multiple) nombre entier n\C3\A9gatif\00"
define void @test_sscanf() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = alloca i8
%6 = alloca i32
%7 = alloca i64
%8 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 @unit_test_int(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %9)
%11 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = call i32 @unit_test_int(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 -42, i32 %12)
%14 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64* %2)
%15 = load i64, i64* %2
%16 = trunc i64 %15 to i32
%17 = call i32 @unit_test_int(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 -720564942, i32 %16)
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8** %3
%18 = load i8*, i8** %3
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %19, i8* %5, i32* %1, i64* %7, i64* %2, i32* %6)
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%22 = call i32 @unit_test_str(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %21)
%23 = load i8, i8* %5
%24 = sext i8 %23 to i32
%25 = call i32 @unit_test_int(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), i32 117, i32 %24)
%26 = load i32, i32* %1
%27 = call i32 @unit_test_int(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 1024, i32 %26)
%28 = load i64, i64* %7
%29 = trunc i64 %28 to i32
%30 = call i32 @unit_test_int(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i32 132542151, i32 %29)
%31 = load i64, i64* %2
%32 = trunc i64 %31 to i32
%33 = call i32 @unit_test_int(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 518580194, i32 %32)
%34 = load i32, i32* %6
%35 = call i32 @unit_test_int(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0), i32 -42, i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"7\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"sscanf (unique) nombre entier positif\00"
@.str.3 = [4 x i8] c"-42\00"
@.str.4 = [39 x i8] c"sscanf (unique) nombre entier n\C3\A9gatif\00"
@.str.5 = [13 x i8] c"132423421234\00"
@.str.6 = [5 x i8] c"%llu\00"
@.str.7 = [48 x i8] c"sscanf (unique) nombre entier positif long long\00"
@.str.8 = [39 x i8] c"Hello u 1024 132542151 13403482082 -42\00"
@.str.9 = [21 x i8] c"%s %c %d %lu %llu %d\00"
@.str.10 = [25 x i8] c"sscanf (multiple) string\00"
@.str.11 = [6 x i8] c"Hello\00"
@.str.12 = [28 x i8] c"sscanf (multiple) caractere\00"
@.str.13 = [39 x i8] c"sscanf (multiple) nombre entier sign\C3\A9\00"
@.str.14 = [53 x i8] c"sscanf (multiple) nombre entier long long non sign\C3\A9\00"
@.str.15 = [48 x i8] c"sscanf (multiple) nombre entier long non sign\C3\A9\00"
@.str.16 = [41 x i8] c"sscanf (multiple) nombre entier n\C3\A9gatif\00"
define void @test_sscanf() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [80 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i64
%7 = bitcast i32* %1 to i8*
%8 = bitcast i64* %2 to i8*
%9 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = call i32 @unit_test_int(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %10)
%12 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = call i32 @unit_test_int(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 -42, i32 %13)
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64* %2)
%16 = load i64, i64* %2
%17 = trunc i64 %16 to i32
%18 = call i32 @unit_test_int(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 -720564942, i32 %17)
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%20 = bitcast i32* %5 to i8*
%21 = bitcast i64* %6 to i8*
%22 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %19, i8* %4, i32* %1, i64* %6, i64* %2, i32* %5)
%23 = call i32 @unit_test_str(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %19)
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = call i32 @unit_test_int(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), i32 117, i32 %25)
%27 = load i32, i32* %1
%28 = call i32 @unit_test_int(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 1024, i32 %27)
%29 = load i64, i64* %6
%30 = trunc i64 %29 to i32
%31 = call i32 @unit_test_int(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i32 132542151, i32 %30)
%32 = load i64, i64* %2
%33 = trunc i64 %32 to i32
%34 = call i32 @unit_test_int(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 518580194, i32 %33)
%35 = load i32, i32* %5
%36 = call i32 @unit_test_int(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0), i32 -42, i32 %35)
ret void
}