#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 in6_addr {
  int /*<<< orphan*/ *s6_addr;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int INET6_ADDRSTRLEN;
int fscanf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *);
char *inet_ntop(int /*<<< orphan*/, struct in6_addr *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
void dec2hex(FILE *f) {
  struct in6_addr addr;
  char buf[10 * INET6_ADDRSTRLEN];
  int done = 0;
  int i;
  while (!done) {
    for (i = 0; i < 16; i++) {
      if (1 != fscanf(f, "%3d:", &(addr.s6_addr[i]))) {
        done = 1;
        break;
      }
    }
    if (done) {
      break;
    }
    printf("%s\n", inet_ntop(AF_INET6, &addr, buf, sizeof(buf)));
  }
}


x86 assembly (clang, -O0):
<dec2hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%ecx
add    %ecx,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1190 <dec2hex+0x60>
jmp    122d <dec2hex+0xfd>
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jge    11ee <dec2hex+0xbe>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe45(%rip),%rsi
call   1050 <fscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     11db <dec2hex+0xab>
movl   $0x1,-0x24(%rbp)
jmp    11ee <dec2hex+0xbe>
jmp    11e0 <dec2hex+0xb0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1197 <dec2hex+0x67>
cmpl   $0x0,-0x24(%rbp)
je     11fd <dec2hex+0xcd>
jmp    122d <dec2hex+0xfd>
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    0x2dd4(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%ecx
lea    -0x10(%rbp),%rsi
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
jmp    117a <dec2hex+0x4a>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%struct.in6_addr = type { i32* }
@INET6_ADDRSTRLEN = global i32 0
@.str = [5 x i8] c"%3d:\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@AF_INET6 = global i32 0
define void @dec2hex(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.in6_addr
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
%8 = load i32, i32* @INET6_ADDRSTRLEN
%9 = mul nsw i32 10, %8
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
store i32 0, i32* %6
br label %13
13: ; preds = %39, %1
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %44
17: ; preds = %13
store i32 0, i32* %7
br label %18
18: ; preds = %32, %17
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 16
br i1 %20, label %21, label %35
21: ; preds = %18
%22 = load i32*, i32** %2
%23 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %3, i32 0, i32 0
%24 = load i32*, i32** %23
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %27)
%29 = icmp ne i32 1, %28
br i1 %29, label %30, label %31
30: ; preds = %21
store i32 1, i32* %6
br label %35
31: ; preds = %21
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %18
35: ; preds = %30, %18
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
br label %44
39: ; preds = %35
%40 = load i32, i32* @AF_INET6
%41 = trunc i64 %10 to i32
%42 = call i8* @inet_ntop(i32 %40, %struct.in6_addr* %3, i8* %12, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %13
44: ; preds = %38, %13
%45 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):