#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 */
char *getsmallvalue(char *, char *);
char *lookupfield(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
char *printVPDfield(char *p, int show_all) {
  char field[3];
  char value[256];
  char *fname;
  field[0] = p[0];
  field[1] = p[1];
  field[2] = 0;
  p += 2;
  p = getsmallvalue(p, value);
  if ((fname = lookupfield(field)) != NULL)
    printf("	%-20s %s\n", fname, value);
  else if (show_all)
    printf("	%-20s %s\n", field, value);
  return p;
}


x86 assembly (clang, -O0):
<printVPDfield>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0xe(%rbp)
movb   $0x0,-0xd(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <getsmallvalue@plt>
mov    %rax,-0x8(%rbp)
lea    -0xf(%rbp),%rdi
call   1030 <lookupfield@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
je     11b2 <printVPDfield+0x82>
mov    -0x118(%rbp),%rsi
lea    -0x110(%rbp),%rdx
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
jmp    11d8 <printVPDfield+0xa8>
cmpl   $0x0,-0xc(%rbp)
je     11d3 <printVPDfield+0xa3>
lea    -0xf(%rbp),%rsi
lea    -0x110(%rbp),%rdx
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
jmp    11d8 <printVPDfield+0xa8>
mov    -0x8(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printVPDfield>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %esi,%r14d
mov    (%rdi),%al
mov    %al,0xd(%rsp)
mov    0x1(%rdi),%al
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
add    $0x2,%rdi
lea    0x10(%rsp),%rsi
call   1040 <getsmallvalue@plt>
mov    %rax,%rbx
lea    0xd(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <lookupfield@plt>
test   %rax,%rax
jne    117b <printVPDfield+0x4b>
mov    %rbp,%rax
test   %r14d,%r14d
je     118f <printVPDfield+0x5f>
lea    0xe7e(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"\09%-20s %s\0A\00"
define i8* @printVPDfield(i8* %0, i32 %1) {
%3 = alloca [3 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = load i8, i8* %0
store i8 %7, i8* %5
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = call i8* @getsmallvalue(i8* %12, i8* %6)
%14 = call i8* @lookupfield(i8* %5)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = icmp eq i32 %1, 0
br i1 %17, label %21, label %18
18: ; preds = %16, %2
%19 = phi i8* [ %14, %2 ], [ %5, %16 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %6)
br label %21
21: ; preds = %18, %16
ret i8* %13
}