#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 *, ...);
void geoip_set_country(const char *country, const char *code, char *loc) {
  if (country && code)
    sprintf(loc, "%s %s", code, country);
  else
    sprintf(loc, "%s", "Country Unknown");
}


x86 assembly (clang, -O0):
<geoip_set_country>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1159 <geoip_set_country+0x49>
cmpq   $0x0,-0x10(%rbp)
je     1159 <geoip_set_country+0x49>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1172 <geoip_set_country+0x62>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
lea    0xe9b(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoip_set_country>:
test   %rdi,%rdi
je     1134 <geoip_set_country+0x24>
mov    %rsi,%rax
test   %rsi,%rsi
je     1134 <geoip_set_country+0x24>
mov    %rdi,%rcx
lea    0xed9(%rip),%rsi
mov    %rdx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
jmp    1030 <sprintf@plt>
movups 0xecb(%rip),%xmm0
movups %xmm0,(%rdx)
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"Country Unknown\00"
define void @geoip_set_country(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** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8*, i8** %6
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
br label %20
17: ; preds = %9, %3
%18 = load i8*, i8** %6
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %17, %12
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.2 = [16 x i8] c"Country Unknown\00"
define void @geoip_set_country(i8* %0, i8* %1, i8* nocapture writeonly %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
br label %10
9: ; preds = %3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %2, i8* align 1 dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 16, i1 false)
br label %10
10: ; preds = %9, %7
ret void
}