#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 */
struct trace_seq {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ trace_seq_printf(struct trace_seq *, char *, ...);
void print_ip6_addr(struct trace_seq *s, char i, unsigned char *buf) {
  int j;
  for (j = 0; j < 16; j += 2) {
    trace_seq_printf(s, "%02x%02x", buf[j], buf[j + 1]);
    if (i == 'I' && j < 14)
      trace_seq_printf(s, ":");
  }
}


x86 assembly (clang, -O0):
<print_ip6_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11a2 <print_ip6_addr+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <trace_seq_printf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x49,%eax
jne    118f <print_ip6_addr+0x7f>
cmpl   $0xe,-0x1c(%rbp)
jge    118f <print_ip6_addr+0x7f>
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1030 <trace_seq_printf@plt>
jmp    1194 <print_ip6_addr+0x84>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <print_ip6_addr+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ip6_addr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
movzbl (%rdx),%edx
movzbl 0x1(%rbx),%ecx
lea    0xed2(%rip),%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
cmp    $0x49,%bpl
jne    122b <print_ip6_addr+0x11b>
lea    0xec3(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x2(%rbx),%edx
movzbl 0x3(%rbx),%ecx
lea    0xe9e(%rip),%r12
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x4(%rbx),%edx
movzbl 0x5(%rbx),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x6(%rbx),%edx
movzbl 0x7(%rbx),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x8(%rbx),%edx
movzbl 0x9(%rbx),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0xa(%rbx),%edx
movzbl 0xb(%rbx),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0xc(%rbx),%edx
movzbl 0xd(%rbx),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
jmp    12b0 <print_ip6_addr+0x1a0>
movzbl 0x2(%rbx),%edx
movzbl 0x3(%rbx),%ecx
lea    0xdc6(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x4(%rbx),%edx
movzbl 0x5(%rbx),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x6(%rbx),%edx
movzbl 0x7(%rbx),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0x8(%rbx),%edx
movzbl 0x9(%rbx),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0xa(%rbx),%edx
movzbl 0xb(%rbx),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0xc(%rbx),%edx
movzbl 0xd(%rbx),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <trace_seq_printf@plt>
movzbl 0xe(%rbx),%edx
movzbl 0xf(%rbx),%ecx
lea    0xd41(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <trace_seq_printf@plt>

LLVM IR (-O0):
%struct.trace_seq = type { i32 }
@.str = [9 x i8] c"%02x%02x\00"
@.str.1 = [2 x i8] c":\00"
define void @print_ip6_addr(%struct.trace_seq* %0, i8 signext %1, i8* %2) {
%4 = alloca %struct.trace_seq*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32
store %struct.trace_seq* %0, %struct.trace_seq** %4
store i8 %1, i8* %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %37, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %40
11: ; preds = %8
%12 = load %struct.trace_seq*, %struct.trace_seq** %4
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %25)
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 73
br i1 %29, label %30, label %36
30: ; preds = %11
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 14
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load %struct.trace_seq*, %struct.trace_seq** %4
%35 = call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %33, %30, %11
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 2
store i32 %39, i32* %7
br label %8
40: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.trace_seq = type { i32 }
@.str = [9 x i8] c"%02x%02x\00"
@.str.1 = [2 x i8] c":\00"
define void @print_ip6_addr(%struct.trace_seq* %0, i8 signext %1, i8* nocapture %2) {
%4 = icmp eq i8 %1, 73
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %9)
br i1 %4, label %54, label %11
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %2, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = getelementptr inbounds i8, i8* %2, i64 3
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %17)
%19 = getelementptr inbounds i8, i8* %2, i64 4
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = getelementptr inbounds i8, i8* %2, i64 5
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %24)
%26 = getelementptr inbounds i8, i8* %2, i64 6
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds i8, i8* %2, i64 7
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %31)
%33 = getelementptr inbounds i8, i8* %2, i64 8
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = getelementptr inbounds i8, i8* %2, i64 9
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %38)
%40 = getelementptr inbounds i8, i8* %2, i64 10
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = getelementptr inbounds i8, i8* %2, i64 11
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %45)
%47 = getelementptr inbounds i8, i8* %2, i64 12
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = getelementptr inbounds i8, i8* %2, i64 13
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %49, i32 %52)
br label %104
54: ; preds = %3
%55 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%56 = getelementptr inbounds i8, i8* %2, i64 2
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = getelementptr inbounds i8, i8* %2, i64 3
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %58, i32 %61)
%63 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%64 = getelementptr inbounds i8, i8* %2, i64 4
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = getelementptr inbounds i8, i8* %2, i64 5
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %66, i32 %69)
%71 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%72 = getelementptr inbounds i8, i8* %2, i64 6
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = getelementptr inbounds i8, i8* %2, i64 7
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %74, i32 %77)
%79 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%80 = getelementptr inbounds i8, i8* %2, i64 8
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = getelementptr inbounds i8, i8* %2, i64 9
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %82, i32 %85)
%87 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%88 = getelementptr inbounds i8, i8* %2, i64 10
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = getelementptr inbounds i8, i8* %2, i64 11
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %90, i32 %93)
%95 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%96 = getelementptr inbounds i8, i8* %2, i64 12
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = getelementptr inbounds i8, i8* %2, i64 13
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %98, i32 %101)
%103 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %104
104: ; preds = %54, %11
%105 = getelementptr inbounds i8, i8* %2, i64 14
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = getelementptr inbounds i8, i8* %2, i64 15
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = tail call i32 (%struct.trace_seq*, i8*, ...) @trace_seq_printf(%struct.trace_seq* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %107, i32 %110)
ret void
}