#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*/ Fail(char *, ...);
int sscanf_s(char *, char const *, char *);
void DoVoidTest(char *inputstr, const char *formatstr) {
  char buf[256] = {0};
  int i;
  int ret;
  ret = sscanf_s(inputstr, formatstr, buf);
  if (ret != 0) {
    Fail("ERROR: Expected sscanf_s to return 0, got %d.\n"
         "Using \"%s\" in \"%s\".\n",
         ret, inputstr, formatstr);
  }
  for (i = 0; i < 256; i++) {
    if (buf[i] != 0) {
      Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" "
           "using \"%s\".\n",
           inputstr, formatstr);
    }
  }
}


x86 assembly (clang, -O0):
<DoVoidTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x110(%rbp),%rdx
call   1050 <sscanf_s@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
je     1199 <DoVoidTest+0x69>
mov    -0x118(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <Fail@plt>
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jge    11fa <DoVoidTest+0xca>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11e1 <DoVoidTest+0xb1>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <Fail@plt>
jmp    11e6 <DoVoidTest+0xb6>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11a3 <DoVoidTest+0x73>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoVoidTest>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
call   1040 <sscanf_s@plt>
test   %eax,%eax
je     11c0 <DoVoidTest+0xa0>
lea    0xe4f(%rip),%rdi
mov    %eax,%esi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <Fail@plt>
lea    0xe7c(%rip),%r15
xor    %ebx,%ebx
jmp    11dd <DoVoidTest+0xbd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11f5 <DoVoidTest+0xd5>
cmpb   $0x0,(%rsp,%rbx,1)
je     11d0 <DoVoidTest+0xb0>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <Fail@plt>
jmp    11d0 <DoVoidTest+0xb0>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [67 x i8] c"ERROR: Expected sscanf_s to return 0, got %d.\0AUsing \22%s\22 in \22%s\22.\0A\00"
@.str.1 = [66 x i8] c"ERROR: Parameter unexpectedly modified scanning \22%s\22 using \22%s\22.\0A\00"
define void @DoVoidTest(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = bitcast [256 x i8]* %5 to i8*
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = call i32 @sscanf_s(i8* %9, i8* %10, i8* %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* %7
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17, i8* %18)
br label %20
20: ; preds = %15, %2
store i32 0, i32* %6
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 256
br i1 %23, label %24, label %39
24: ; preds = %21
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i8*, i8** %4
%34 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %31, %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %21
39: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [67 x i8] c"ERROR: Expected sscanf_s to return 0, got %d.\0AUsing \22%s\22 in \22%s\22.\0A\00"
@.str.1 = [66 x i8] c"ERROR: Parameter unexpectedly modified scanning \22%s\22 using \22%s\22.\0A\00"
define void @DoVoidTest(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @sscanf_s(i8* %0, i8* %1, i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %0, i8* %1)
br label %9
9: ; preds = %7, %2
br label %10
10: ; preds = %9, %17
%11 = phi i64 [ %18, %17 ], [ 0, %9 ]
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call i32 (i8*, ...) @Fail(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %17
17: ; preds = %10, %15
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, 256
br i1 %19, label %20, label %10
20: ; preds = %17
ret void
}