#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*/ free(char *);
char *safe_malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *parse_get(char *buf) {
  char *req_t = safe_malloc(256);
  char *file = safe_malloc(256);
  sscanf(buf, "%s %s", req_t, file);
  if (!strcmp(req_t, "GET ")) {
    free(req_t);
    free(file);
    return NULL;
  }
  free(req_t);
  return file;
}


x86 assembly (clang, -O0):
<parse_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x100,%edi
call   1040 <safe_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
call   1040 <safe_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe85(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11b8 <parse_get+0x78>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <parse_get+0x89>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_get>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x100,%edi
call   1040 <safe_malloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   1040 <safe_malloc@plt>
mov    %rax,%r15
lea    0xe95(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <sscanf@plt>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
jne    11a1 <parse_get+0x61>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [5 x i8] c"GET \00"
define i8* @parse_get(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = call i8* @safe_malloc(i32 256)
store i8* %6, i8** %4
%7 = call i8* @safe_malloc(i32 256)
store i8* %7, i8** %5
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = load i8*, i8** %4
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = load i8*, i8** %5
%19 = call i32 @free(i8* %18)
store i8* null, i8** %2
br label %24
20: ; preds = %1
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = load i8*, i8** %5
store i8* %23, i8** %2
br label %24
24: ; preds = %20, %15
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [5 x i8] c"GET \00"
define i8* @parse_get(i8* nocapture %0) {
%2 = tail call i8* @safe_malloc(i32 256)
%3 = tail call i8* @safe_malloc(i32 256)
%4 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3)
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
%7 = tail call i32 @free(i8* %2)
br i1 %6, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @free(i8* %3)
br label %10
10: ; preds = %1, %8
%11 = phi i8* [ null, %8 ], [ %3, %1 ]
ret i8* %11
}