#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 const *,
                                    unsigned char, unsigned char, unsigned char,
                                    unsigned char);
void print_ip4_addr(struct trace_seq *s, char i, unsigned char *buf) {
  const char *fmt;
  if (i == 'i') {
    fmt = "%03d.%03d.%03d.%03d";
  } else {
    fmt = "%d.%d.%d.%d";
  }
  trace_seq_printf(s, fmt, buf[0], buf[1], buf[2], buf[3]);
}


x86 assembly (clang, -O0):
<print_ip4_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x69,%eax
jne    1143 <print_ip4_addr+0x33>
lea    0xec6(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    114e <print_ip4_addr+0x3e>
lea    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%dl
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x18(%rbp),%rax
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl 0x3(%rax),%r9d
call   1030 <trace_seq_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ip4_addr>:
cmp    $0x69,%sil
lea    0xee5(%rip),%rax
lea    0xef2(%rip),%rsi
cmove  %rax,%rsi
movzbl (%rdx),%eax
movzbl 0x1(%rdx),%ecx
movzbl 0x2(%rdx),%r8d
movzbl 0x3(%rdx),%r9d
mov    %eax,%edx
jmp    1030 <trace_seq_printf@plt>

LLVM IR (-O0):
%struct.trace_seq = type { i32 }
@.str = [20 x i8] c"%03d.%03d.%03d.%03d\00"
@.str.1 = [12 x i8] c"%d.%d.%d.%d\00"
define void @print_ip4_addr(%struct.trace_seq* %0, i8 signext %1, i8* %2) {
%4 = alloca %struct.trace_seq*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
store %struct.trace_seq* %0, %struct.trace_seq** %4
store i8 %1, i8* %5
store i8* %2, i8** %6
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 105
br i1 %10, label %11, label %12
11: ; preds = %3
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %7
br label %13
12: ; preds = %3
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %13
13: ; preds = %12, %11
%14 = load %struct.trace_seq*, %struct.trace_seq** %4
%15 = load i8*, i8** %7
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = call i32 @trace_seq_printf(%struct.trace_seq* %14, i8* %15, i8 zeroext %18, i8 zeroext %21, i8 zeroext %24, i8 zeroext %27)
ret void
}

LLVM IR (-O2):
%struct.trace_seq = type { i32 }
@.str = [20 x i8] c"%03d.%03d.%03d.%03d\00"
@.str.1 = [12 x i8] c"%d.%d.%d.%d\00"
define void @print_ip4_addr(%struct.trace_seq* %0, i8 signext %1, i8* nocapture %2) {
%4 = icmp eq i8 %1, 105
%5 = select i1 %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0)
%6 = load i8, i8* %2
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %2, i64 2
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %2, i64 3
%12 = load i8, i8* %11
%13 = tail call i32 @trace_seq_printf(%struct.trace_seq* %0, i8* %5, i8 zeroext %6, i8 zeroext %8, i8 zeroext %10, i8 zeroext %12)
ret void
}