#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 scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_128(uint64_t *v) {
  if (v[0] > 0) {
    printf("%llx", (long long unsigned int)v[0]);
    printf("%016llx", (long long unsigned int)v[1]);
  } else {
    printf("%llx", (long long unsigned int)v[1]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_128>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jle    115a <print_128+0x4a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1170 <print_128+0x60>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_128>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rsi
lea    0xed2(%rip),%rdi
test   %rsi,%rsi
jle    1141 <print_128+0x21>
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    0x8(%rbx),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%llx\00"
@.str.1 = [8 x i8] c"%016llx\00"
define void @print_128(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = icmp sgt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %2)
br label %6
6: ; preds = %1, %4
%7 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ]
%8 = getelementptr inbounds i64, i64* %0, i64 1
%9 = load i64, i64* %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %7, i64 %9)
%11 = tail call i32 @putchar(i32 10)
ret void
}