#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 *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *realloc(char *, scalar_t__);
scalar_t__ strlen(char *);
char *strstr(char *, char *);
char *get_response_body(char *response) {
  char *res_start = strstr(response, "{\"twoFactorAuth\":");
  if (res_start == NULL) {
    return NULL;
  } else {
    char *res_body = malloc(500);
    memset(res_body, 0, 500);
    int i = 0;
    while ((res_start + i)[0] != '\r' && (res_start + i)[0] != '\n' &&
           i < 500) {
      (res_body + i)[0] = (res_start + i)[0];
      ++i;
    }
    res_body = realloc(res_body, strlen(res_body) + 1);
    return res_body;
  }
}


x86 assembly (clang, -O0):
<get_response_body>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <get_response_body+0x38>
movq   $0x0,-0x8(%rbp)
jmp    124f <get_response_body+0xff>
mov    $0x1f4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x25(%rbp)
je     11ee <get_response_body+0x9e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x25(%rbp)
je     11ee <get_response_body+0x9e>
cmpl   $0x1f4,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11fe <get_response_body+0xae>
jmp    1222 <get_response_body+0xd2>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <get_response_body+0x5d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
call   1060 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_response_body>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     11c9 <get_response_body+0x79>
mov    %rax,%r14
mov    $0x1f4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
mov    (%r14),%al
cmp    $0xd,%al
je     11ae <get_response_body+0x5e>
xor    %ecx,%ecx
nopl   (%rax)
cmp    $0xa,%al
je     11ae <get_response_body+0x5e>
cmp    $0x1f3,%rcx
ja     11ae <get_response_body+0x5e>
mov    %al,(%rbx,%rcx,1)
movzbl 0x1(%r14,%rcx,1),%eax
add    $0x1,%rcx
cmp    $0xd,%al
jne    1190 <get_response_body+0x40>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <realloc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"{\22twoFactorAuth\22:\00"
define noalias i8* @get_response_body(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %25, label %4
4: ; preds = %1
%5 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%6 = tail call i32 @memset(i8* %5, i32 0, i32 500)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 13
br i1 %8, label %21, label %9
9: ; preds = %4, %15
%10 = phi i64 [ %17, %15 ], [ 0, %4 ]
%11 = phi i8 [ %19, %15 ], [ %7, %4 ]
%12 = icmp ne i8 %11, 10
%13 = icmp ult i64 %10, 500
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = getelementptr inbounds i8, i8* %5, i64 %10
store i8 %11, i8* %16
%17 = add nuw nsw i64 %10, 1
%18 = getelementptr inbounds i8, i8* %2, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 13
br i1 %20, label %21, label %9
21: ; preds = %9, %15, %4
%22 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%23 = add nsw i64 %22, 1
%24 = tail call i8* @realloc(i8* %5, i64 %23)
br label %25
25: ; preds = %1, %21
%26 = phi i8* [ %24, %21 ], [ null, %1 ]
ret i8* %26
}