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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char const *, char const *, void *);
void scan(const char *s, const char *t, const char *f, void *p, size_t n) {
  char *v;
  size_t i;
  if (sscanf(s, f, p) != 1)
    return;
  v = p;
  printf("%-16s: ", t);
  for (i = 0; i < n; i++)
    printf("%02x ", v[i] & 0xff);
  printf("\n");
}


x86 assembly (clang, -O0):
<scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     115b <scan+0x3b>
jmp    11ca <scan+0xaa>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11bc <scan+0x9c>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    117d <scan+0x5d>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r12
mov    %rsi,%r15
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    119d <scan+0x6d>
lea    0xea8(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
je     1188 <scan+0x58>
lea    0xe9a(%rip),%r15
xor    %ebx,%ebx
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <scan+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%-16s: \00"
@.str.1 = [6 x i8] c"%02x \00"
define void @scan(i8* nocapture %0, i8* %1, i8* nocapture %2, i8* %3, i64 %4) {
%6 = tail call i32 @sscanf(i8* %0, i8* %2, i8* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = icmp eq i64 %4, 0
br i1 %10, label %19, label %11
11: ; preds = %8, %11
%12 = phi i64 [ %17, %11 ], [ 0, %8 ]
%13 = getelementptr inbounds i8, i8* %3, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw i64 %12, 1
%18 = icmp eq i64 %17, %4
br i1 %18, label %19, label %11
19: ; preds = %11, %8
%20 = tail call i32 @putchar(i32 10)
br label %21
21: ; preds = %5, %19
ret void
}