#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*/ sprintf(char *, char *, char const *, char const *);
void geoip_set_city(const char *city, const char *region, char *loc) {
  sprintf(loc, "%s, %s", city ? city : "N/A City",
          region ? region : "N/A Region");
}


x86 assembly (clang, -O0):
<geoip_set_city>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1144 <geoip_set_city+0x34>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1154 <geoip_set_city+0x44>
lea    0xebc(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1154 <geoip_set_city+0x44>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <geoip_set_city+0x64>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1184 <geoip_set_city+0x74>
lea    0xe95(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1184 <geoip_set_city+0x74>
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rcx
lea    0xe69(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoip_set_city>:
mov    %rdx,%rax
test   %rdi,%rdi
lea    0xeea(%rip),%rdx
cmovne %rdi,%rdx
test   %rsi,%rsi
lea    0xee5(%rip),%rcx
cmovne %rsi,%rcx
lea    0xeca(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%s, %s\00"
@.str.1 = [9 x i8] c"N/A City\00"
@.str.2 = [11 x i8] c"N/A Region\00"
define void @geoip_set_city(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = load i8*, i8** %4
br label %13
12: ; preds = %3
br label %13
13: ; preds = %12, %10
%14 = phi i8* [ %11, %10 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %12 ]
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i8*, i8** %5
br label %20
19: ; preds = %13
br label %20
20: ; preds = %19, %17
%21 = phi i8* [ %18, %17 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %19 ]
%22 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s, %s\00"
@.str.1 = [9 x i8] c"N/A City\00"
@.str.2 = [11 x i8] c"N/A Region\00"
define void @geoip_set_city(i8* %0, i8* %1, i8* nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
%5 = select i1 %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0
%6 = icmp eq i8* %1, null
%7 = select i1 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %1
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %7)
ret void
}