#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*/ assert(int);
char *malloc(size_t const);
int /*<<< orphan*/ memcpy(char *, char *, size_t const);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *, char const *);
int sscanf(char const *, char *, char *, char *);
int strlen(char const *);
char *parse_line(const char *line, const char *field) {
  assert(line && field);
  const char *format_part = " %s %s ";
  size_t format_size = strlen(field) + strlen(format_part) + 2;
  char format[format_size];
  snprintf(format, format_size, " %s%s", field, format_part);
  char buffer[256] = {'\0'};
  char aux_buffer[256] = {'\0'};
  int parse_success = sscanf(line, format, buffer, aux_buffer);
  if (parse_success != 1)
    return NULL;
  const size_t len = strlen(buffer);
  char *value = malloc(len + 1);
  if (!value)
    return NULL;
  memcpy(value, buffer, len + 1);
  return value;
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x259(%rbp)
je     11a4 <parse_line+0x34>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x259(%rbp)
mov    -0x259(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1060 <assert@plt>
lea    0xe44(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x26c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x26c(%rbp),%ecx
mov    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x2(%rax,%rcx,1),%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x268(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xddd(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x268(%rbp),%rsi
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x240(%rbp),%rcx
call   1090 <sscanf@plt>
mov    %eax,-0x244(%rbp)
cmpl   $0x1,-0x244(%rbp)
je     129e <parse_line+0x12e>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x248(%rbp)
jmp    1322 <parse_line+0x1b2>
lea    -0x140(%rbp),%rdi
call   1030 <strlen@plt>
cltq
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x258(%rbp)
cmpq   $0x0,-0x258(%rbp)
jne    12ef <parse_line+0x17f>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x248(%rbp)
jmp    1322 <parse_line+0x1b2>
mov    -0x258(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x250(%rbp),%rdx
add    $0x1,%rdx
call   1070 <memcpy@plt>
mov    -0x258(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x248(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xe61(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x2,%eax
movslq %eax,%rsi
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe41(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
mov    %r12,%r8
call   1040 <snprintf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0xd0(%rbp)
movaps %xmm0,-0xe0(%rbp)
movaps %xmm0,-0xf0(%rbp)
movaps %xmm0,-0x100(%rbp)
movaps %xmm0,-0x110(%rbp)
movaps %xmm0,-0x120(%rbp)
movaps %xmm0,-0x130(%rbp)
movaps %xmm0,-0x140(%rbp)
movaps %xmm0,-0x150(%rbp)
movaps %xmm0,-0x160(%rbp)
movaps %xmm0,-0x170(%rbp)
movaps %xmm0,-0x180(%rbp)
movaps %xmm0,-0x190(%rbp)
movaps %xmm0,-0x1a0(%rbp)
movaps %xmm0,-0x1b0(%rbp)
movaps %xmm0,-0x1c0(%rbp)
movaps %xmm0,-0x1d0(%rbp)
movaps %xmm0,-0x1e0(%rbp)
movaps %xmm0,-0x1f0(%rbp)
movaps %xmm0,-0x200(%rbp)
movaps %xmm0,-0x210(%rbp)
movaps %xmm0,-0x220(%rbp)
lea    -0x120(%rbp),%rdx
lea    -0x220(%rbp),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    12fb <parse_line+0x19b>
lea    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
movslq %eax,%r14
add    $0x1,%r14
mov    %r14,%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     12fb <parse_line+0x19b>
mov    %rax,%rbx
lea    -0x120(%rbp),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <memcpy@plt>
jmp    12fd <parse_line+0x19d>
xor    %ebx,%ebx
mov    %rbx,%rax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c" %s %s \00"
@.str.1 = [6 x i8] c" %s%s\00"
define i8* @parse_line(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br label %21
21: ; preds = %18, %2
%22 = phi i1 [ false, %2 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %6
%25 = load i8*, i8** %5
%26 = call i32 @strlen(i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %26, %28
%30 = add nsw i32 %29, 2
%31 = sext i32 %30 to i64
store i64 %31, i64* %7
%32 = load i64, i64* %7
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %8
%34 = alloca i8, i64 %32
store i64 %32, i64* %9
%35 = load i64, i64* %7
%36 = load i8*, i8** %5
%37 = load i8*, i8** %6
%38 = call i32 @snprintf(i8* %34, i64 %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %36, i8* %37)
%39 = bitcast [256 x i8]* %10 to i8*
%40 = bitcast [256 x i8]* %11 to i8*
%41 = load i8*, i8** %4
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%44 = call i32 @sscanf(i8* %41, i8* %34, i8* %42, i8* %43)
store i32 %44, i32* %12
%45 = load i32, i32* %12
%46 = icmp ne i32 %45, 1
br i1 %46, label %47, label %48
47: ; preds = %21
store i8* null, i8** %3
store i32 1, i32* %13
br label %65
48: ; preds = %21
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = sext i32 %50 to i64
store i64 %51, i64* %14
%52 = load i64, i64* %14
%53 = add i64 %52, 1
%54 = call i8* @malloc(i64 %53)
store i8* %54, i8** %15
%55 = load i8*, i8** %15
%56 = icmp ne i8* %55, null
br i1 %56, label %58, label %57
57: ; preds = %48
store i8* null, i8** %3
store i32 1, i32* %13
br label %65
58: ; preds = %48
%59 = load i8*, i8** %15
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%61 = load i64, i64* %14
%62 = add i64 %61, 1
%63 = call i32 @memcpy(i8* %59, i8* %60, i64 %62)
%64 = load i8*, i8** %15
store i8* %64, i8** %3
store i32 1, i32* %13
br label %65
65: ; preds = %58, %57, %47
%66 = load i8*, i8** %8
%67 = load i8*, i8** %3
ret i8* %67
}

LLVM IR (-O2):
@.str = [8 x i8] c" %s %s \00"
@.str.1 = [6 x i8] c" %s%s\00"
define i8* @parse_line(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @strlen(i8* %1)
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = add i32 %10, 2
%13 = add i32 %12, %11
%14 = sext i32 %13 to i64
%15 = alloca i8, i64 %14
%16 = call i32 @snprintf(i8* %15, i64 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = call i32 @sscanf(i8* %0, i8* %15, i8* %17, i8* %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = call i32 @strlen(i8* %17)
%23 = sext i32 %22 to i64
%24 = add nsw i64 %23, 1
%25 = call i8* @malloc(i64 %24)
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %21
%28 = call i32 @memcpy(i8* %25, i8* %17, i64 %24)
br label %29
29: ; preds = %27, %21, %2
%30 = phi i8* [ null, %2 ], [ %25, %27 ], [ null, %21 ]
ret i8* %30
}