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

/* Variables and functions */
int sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int swprintf(int /*<<< orphan*/ *, int, char *, char *);
scalar_t__ wcscmp(int /*<<< orphan*/ *, char *);
int t3(void) {
  char buf[80];
  wchar_t wbuf[80];
  int result = 0;
  int retval;
  retval = sprintf(buf, "%p", (char *)NULL);
  result |= retval != 5 || strcmp(buf, "(nil)") != 0;
  retval = swprintf(wbuf, sizeof(wbuf) / sizeof(wbuf[0]), L"%p", (char *)NULL);
  result |= retval != 5 || wcscmp(wbuf, L"(nil)") != 0;
  return result;
}


x86 assembly (clang, -O0):
<t3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x194(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea0(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    %eax,-0x198(%rbp)
mov    $0x1,%al
cmpl   $0x5,-0x198(%rbp)
mov    %al,-0x199(%rbp)
jne    11a1 <t3+0x61>
lea    -0x50(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x199(%rbp)
mov    -0x199(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x194(%rbp),%eax
mov    %eax,-0x194(%rbp)
lea    -0x190(%rbp),%rdi
mov    $0x50,%esi
lea    0xe41(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <swprintf@plt>
mov    %eax,-0x198(%rbp)
mov    $0x1,%al
cmpl   $0x5,-0x198(%rbp)
mov    %al,-0x19a(%rbp)
jne    120f <t3+0xcf>
lea    -0x190(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19a(%rbp)
mov    -0x19a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x194(%rbp),%eax
mov    %eax,-0x194(%rbp)
mov    -0x194(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t3>:
push   %rbp
push   %rbx
sub    $0x198,%rsp
lea    0xeb0(%rip),%rsi
mov    %rsp,%rdi
xor    %edx,%edx
call   1060 <sprintf@plt>
mov    $0x1,%ebx
mov    $0x1,%ebp
cmp    $0x5,%eax
jne    1181 <t3+0x41>
lea    0xe93(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
lea    0xe84(%rip),%rdx
lea    0x50(%rsp),%rdi
mov    $0x50,%esi
xor    %ecx,%ecx
call   1050 <swprintf@plt>
cmp    $0x5,%eax
jne    11b7 <t3+0x77>
lea    0xe73(%rip),%rsi
lea    0x50(%rsp),%rdi
call   1030 <wcscmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
or     %ebp,%ebx
mov    %ebx,%eax
add    $0x198,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%p\00"
@.str.1 = [6 x i8] c"(nil)\00"
@.str.2 = [3 x i32] [i32 37, i32 112, i32 0]
@.str.3 = [6 x i32] [i32 40, i32 110, i32 105, i32 108, i32 41, i32 0]
define i32 @t3() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 5
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %9, %0
%14 = phi i1 [ true, %0 ], [ %12, %9 ]
%15 = zext i1 %14 to i32
%16 = load i32, i32* %3
%17 = or i32 %16, %15
store i32 %17, i32* %3
%18 = getelementptr inbounds [80 x i32], [80 x i32]* %2, i64 0, i64 0
%19 = call i32 @swprintf(i32* %18, i32 80, i8* bitcast ([3 x i32]* @.str.2 to i8*), i8* null)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 5
br i1 %21, label %26, label %22
22: ; preds = %13
%23 = getelementptr inbounds [80 x i32], [80 x i32]* %2, i64 0, i64 0
%24 = call i64 @wcscmp(i32* %23, i8* bitcast ([6 x i32]* @.str.3 to i8*))
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %22, %13
%27 = phi i1 [ true, %13 ], [ %25, %22 ]
%28 = zext i1 %27 to i32
%29 = load i32, i32* %3
%30 = or i32 %29, %28
store i32 %30, i32* %3
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"%p\00"
@.str.1 = [6 x i8] c"(nil)\00"
@.str.2 = [3 x i32] [i32 37, i32 112, i32 0]
@.str.3 = [6 x i32] [i32 40, i32 110, i32 105, i32 108, i32 41, i32 0]
define i32 @t3() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i32]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = bitcast [80 x i32]* %2 to i8*
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null)
%6 = icmp eq i32 %5, 5
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %0
%12 = phi i32 [ 1, %0 ], [ %10, %7 ]
%13 = getelementptr inbounds [80 x i32], [80 x i32]* %2, i64 0, i64 0
%14 = call i32 @swprintf(i32* %13, i32 80, i8* bitcast ([3 x i32]* @.str.2 to i8*), i8* null)
%15 = icmp eq i32 %14, 5
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = call i64 @wcscmp(i32* %13, i8* bitcast ([6 x i32]* @.str.3 to i8*))
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %11
%21 = phi i32 [ 1, %11 ], [ %19, %16 ]
%22 = or i32 %21, %12
ret i32 %22
}