#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*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ IsLogOn(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int snprintf(char *, int, char const *, int /*<<< orphan*/);
void PrintLogHexagon(const char *fmt, va_list ap) {
  char buffer[200];
  const int count = snprintf(buffer, 200, fmt, ap);
  buffer[count] = 0;
  do {
    if (!IsLogOn(0))
      break;
    printf("%s"
           "\n",
           buffer);
  } while (0);
}


x86 assembly (clang, -O0):
<PrintLogHexagon>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    $0xc8,%esi
call   1050 <snprintf@plt>
mov    %eax,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
xor    %edi,%edi
call   1030 <IsLogOn@plt>
cmp    $0x0,%eax
jne    1184 <PrintLogHexagon+0x54>
jmp    1197 <PrintLogHexagon+0x67>
lea    -0xe0(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintLogHexagon>:
sub    $0xc8,%rsp
mov    %esi,%ecx
mov    %rdi,%rdx
mov    %rsp,%rdi
mov    $0xc8,%esi
call   1050 <snprintf@plt>
cltq
movb   $0x0,(%rsp,%rax,1)
xor    %edi,%edi
call   1030 <IsLogOn@plt>
test   %eax,%eax
je     1169 <PrintLogHexagon+0x39>
lea    0xe9f(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0xc8,%rsp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @PrintLogHexagon(i8* %0, i32 %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 200, i8* %0, i32 %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %6
store i8 0, i8* %7
%8 = call i32 @IsLogOn(i32 0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %12
12: ; preds = %2, %10
ret void
}