#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 */
typedef int /*<<< orphan*/ wint_t;
typedef int wchar_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char *, int *, char, int /*<<< orphan*/,
                          int);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ wcscmp(int *, char *);
int wscanf(char *, char *, int *, char *, int *, int *);
int main(int argc, char *argv[]) {
  int n;
  int result = 0;
  char buf1[20];
  wchar_t wbuf2[20];
  char c3;
  wchar_t wc4;
  int d;
  puts("Test 1");
  n = wscanf(L"%s %S %c%C %d", buf1, wbuf2, &c3, &wc4, &d);
  if (n != 5 || strcmp(buf1, "Hello") != 0 || wcscmp(wbuf2, L"World") != 0 ||
      c3 != '!' || wc4 != L'!' || d != 42) {
    printf("*** FAILED, n = %d, buf1 = \"%s\", wbuf2 = L\"%S\", c3 = '%c', wc4 "
           "= L'%C', d = %d\n",
           n, buf1, wbuf2, c3, (wint_t)wc4, d);
    result = 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    -0x30(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xed5(%rip),%rdi
lea    -0x81(%rbp),%rcx
lea    -0x88(%rbp),%r8
lea    -0x8c(%rbp),%r9
call   1060 <wscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jne    1210 <main+0xc0>
lea    -0x30(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1210 <main+0xc0>
lea    -0x80(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%rax
jne    1210 <main+0xc0>
movsbl -0x81(%rbp),%eax
cmp    $0x21,%eax
jne    1210 <main+0xc0>
cmpl   $0x21,-0x88(%rbp)
jne    1210 <main+0xc0>
cmpl   $0x2a,-0x8c(%rbp)
je     1249 <main+0xf9>
mov    -0x14(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    -0x80(%rbp),%rcx
mov    -0x81(%rbp),%r8b
mov    -0x88(%rbp),%r9d
mov    -0x8c(%rbp),%eax
lea    0xdd7(%rip),%rdi
movsbl %r8b,%r8d
mov    %eax,(%rsp)
call   1050 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xef5(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x40(%rsp),%rdx
lea    0x17(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
call   1060 <wscanf@plt>
mov    %eax,%ebx
cmp    $0x5,%eax
jne    11a6 <main+0x56>
lea    0xe70(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11de <main+0x8e>
movsbl 0x17(%rsp),%r8d
mov    0x1c(%rsp),%r9d
mov    0x18(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe4e(%rip),%rdi
lea    0x20(%rsp),%rdx
lea    0x40(%rsp),%rcx
mov    %ebx,%esi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x90,%rsp
pop    %rbx
ret
lea    0xeb3(%rip),%rsi
lea    0x40(%rsp),%rdi
call   1030 <wcscmp@plt>
test   %rax,%rax
jne    11a6 <main+0x56>
cmpb   $0x21,0x17(%rsp)
jne    11a6 <main+0x56>
cmpl   $0x21,0x1c(%rsp)
jne    11a6 <main+0x56>
xor    %eax,%eax
cmpl   $0x2a,0x18(%rsp)
je     11d5 <main+0x85>
jmp    11a6 <main+0x56>

LLVM IR (-O0):
@.str = [7 x i8] c"Test 1\00"
@.str.1 = [14 x i32] [i32 37, i32 115, i32 32, i32 37, i32 83, i32 32, i32 37, i32 99, i32 37, i32 67, i32 32, i32 37, i32 100, i32 0]
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [6 x i32] [i32 87, i32 111, i32 114, i32 108, i32 100, i32 0]
@.str.4 = [80 x i8] c"*** FAILED, n = %d, buf1 = \22%s\22, wbuf2 = L\22%S\22, c3 = '%c', wc4 = L'%C', d = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
%9 = alloca [20 x i32]
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%13 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %9, i64 0, i64 0
%16 = call i32 @wscanf(i8* bitcast ([14 x i32]* @.str.1 to i8*), i8* %14, i32* %15, i8* %10, i32* %11, i32* %12)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 5
br i1 %18, label %37, label %19
19: ; preds = %2
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %19
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %9, i64 0, i64 0
%25 = call i64 @wcscmp(i32* %24, i8* bitcast ([6 x i32]* @.str.3 to i8*))
%26 = icmp ne i64 %25, 0
br i1 %26, label %37, label %27
27: ; preds = %23
%28 = load i8, i8* %10
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 33
br i1 %30, label %37, label %31
31: ; preds = %27
%32 = load i32, i32* %11
%33 = icmp ne i32 %32, 33
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %12
%36 = icmp ne i32 %35, 42
br i1 %36, label %37, label %45
37: ; preds = %34, %31, %27, %23, %19, %2
%38 = load i32, i32* %6
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %9, i64 0, i64 0
%41 = load i8, i8* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.4, i64 0, i64 0), i32 %38, i8* %39, i32* %40, i8 signext %41, i32 %42, i32 %43)
store i32 1, i32* %7
br label %45
45: ; preds = %37, %34
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
@.str = [7 x i8] c"Test 1\00"
@.str.1 = [14 x i32] [i32 37, i32 115, i32 32, i32 37, i32 83, i32 32, i32 37, i32 99, i32 37, i32 67, i32 32, i32 37, i32 100, i32 0]
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [6 x i32] [i32 87, i32 111, i32 114, i32 108, i32 100, i32 0]
@.str.4 = [80 x i8] c"*** FAILED, n = %d, buf1 = \22%s\22, wbuf2 = L\22%S\22, c3 = '%c', wc4 = L'%C', d = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i8]
%4 = alloca [20 x i32]
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = bitcast [20 x i32]* %4 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%14 = call i32 @wscanf(i8* bitcast ([14 x i32]* @.str.1 to i8*), i8* %8, i32* %13, i8* %5, i32* %6, i32* %7)
%15 = icmp eq i32 %14, 5
br i1 %15, label %16, label %31
16: ; preds = %2
%17 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = call i64 @wcscmp(i32* %13, i8* bitcast ([6 x i32]* @.str.3 to i8*))
%21 = icmp ne i64 %20, 0
%22 = load i8, i8* %5
%23 = icmp ne i8 %22, 33
%24 = select i1 %21, i1 true, i1 %23
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 33
%27 = select i1 %24, i1 true, i1 %26
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 42
%30 = select i1 %27, i1 true, i1 %29
br i1 %30, label %31, label %36
31: ; preds = %19, %16, %2
%32 = load i8, i8* %5
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.4, i64 0, i64 0), i32 %14, i8* %8, i32* %13, i8 signext %32, i32 %33, i32 %34)
br label %36
36: ; preds = %19, %31
%37 = phi i32 [ 1, %31 ], [ 0, %19 ]
ret i32 %37
}