#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*/ decode_header_value(char *);
scalar_t__ safe_malloc(char *, int, scalar_t__);
char *strcpy(char *, char *);
scalar_t__ strlen(char *);
char *copy_header_value(char *text) {
  char *p;
  for (p = text; *p && (*p != ':'); p++)
    ;
  if (!*p)
    return NULL;
  p++;
  p = strcpy(
      (char *)safe_malloc(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/rc0/mairix/refs/heads/master/rfc822.c",
          372, 1 + strlen(p)),
      (p));
  decode_header_value(p);
  return p;
}


x86 assembly (clang, -O0):
<copy_header_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1179 <copy_header_value+0x39>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1189 <copy_header_value+0x49>
jmp    119f <copy_header_value+0x5f>
jmp    118e <copy_header_value+0x4e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1154 <copy_header_value+0x14>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11b9 <copy_header_value+0x79>
movq   $0x0,-0x8(%rbp)
jmp    1207 <copy_header_value+0xc7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xe24(%rip),%rdi
mov    $0x174,%esi
call   1040 <safe_malloc@plt>
mov    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <decode_header_value@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_header_value>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
test   %al,%al
je     1195 <copy_header_value+0x55>
cmp    $0x3a,%al
jne    1150 <copy_header_value+0x10>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0xe8d(%rip),%rdi
mov    $0x174,%esi
call   1040 <safe_malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <decode_header_value@plt>
jmp    1198 <copy_header_value+0x58>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [128 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/mairix/refs/heads/master/rfc822.c\00"
define i8* @copy_header_value(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
store i8* %5, i8** %4
br label %6
6: ; preds = %19, %1
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 58
br label %16
16: ; preds = %11, %6
%17 = phi i1 [ false, %6 ], [ %15, %11 ]
br i1 %17, label %18, label %22
18: ; preds = %16
br label %19
19: ; preds = %18
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
br label %6
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i8* null, i8** %2
br label %40
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
%30 = load i8*, i8** %4
%31 = call i64 @strlen(i8* %30)
%32 = add nsw i64 1, %31
%33 = call i64 @safe_malloc(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 372, i64 %32)
%34 = inttoptr i64 %33 to i8*
%35 = load i8*, i8** %4
%36 = call i8* @strcpy(i8* %34, i8* %35)
store i8* %36, i8** %4
%37 = load i8*, i8** %4
%38 = call i32 @decode_header_value(i8* %37)
%39 = load i8*, i8** %4
store i8* %39, i8** %2
br label %40
40: ; preds = %27, %26
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
@.str = [128 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/mairix/refs/heads/master/rfc822.c\00"
define i8* @copy_header_value(i8* nocapture %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %15
i8 58, label %7
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 1
%9 = tail call i64 @strlen(i8* %8)
%10 = add nsw i64 %9, 1
%11 = tail call i64 @safe_malloc(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 372, i64 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i8* @strcpy(i8* dereferenceable(1) %12, i8* %8)
%14 = tail call i32 @decode_header_value(i8* %12)
br label %15
15: ; preds = %2, %7
%16 = phi i8* [ %12, %7 ], [ null, %2 ]
ret i8* %16
}