#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*/ printf(char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int /*<<< orphan*/ zeroblog_extract_value(char *, char *);
int test_zeroblog_extract_value() {
  char teststr[512], result[512];
  sprintf(teststr, "%s", "\"body\": \"This is some text\"\n");
  zeroblog_extract_value(teststr, result);
  if (result[0] == 0)
    return 1;
  if (result[0] != 'T') {
    printf("%s\n", result);
    return 2;
  }
  if (result[1] != 'h')
    return 3;
  if (result[strlen(result) - 2] != 'x') {
    printf("%s\n%c\n", result, result[strlen(result) - 2]);
    return 4;
  }
  if (result[strlen(result) - 1] != 't')
    return 5;
  return 0;
}


x86 assembly (clang, -O0):
<test_zeroblog_extract_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x210(%rbp),%rdi
lea    0xea7(%rip),%rsi
lea    0xea3(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <zeroblog_extract_value@plt>
movsbl -0x410(%rbp),%eax
cmp    $0x0,%eax
jne    1194 <test_zeroblog_extract_value+0x54>
movl   $0x1,-0x4(%rbp)
jmp    1280 <test_zeroblog_extract_value+0x140>
movsbl -0x410(%rbp),%eax
cmp    $0x54,%eax
je     11c5 <test_zeroblog_extract_value+0x85>
lea    -0x410(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1280 <test_zeroblog_extract_value+0x140>
movsbl -0x40f(%rbp),%eax
cmp    $0x68,%eax
je     11e1 <test_zeroblog_extract_value+0xa1>
movl   $0x3,-0x4(%rbp)
jmp    1280 <test_zeroblog_extract_value+0x140>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x2,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x78,%eax
je     124b <test_zeroblog_extract_value+0x10b>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x418(%rbp),%rsi
sub    $0x2,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%edx
ff
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1280 <test_zeroblog_extract_value+0x140>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x74,%eax
je     1279 <test_zeroblog_extract_value+0x139>
movl   $0x5,-0x4(%rbp)
jmp    1280 <test_zeroblog_extract_value+0x140>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_zeroblog_extract_value>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
movups 0xec0(%rip),%xmm0
movaps %xmm0,0x200(%rsp)
movups 0xebe(%rip),%xmm0
movups %xmm0,0x20d(%rsp)
lea    0x200(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <zeroblog_extract_value@plt>
mov    (%rsp),%al
test   %al,%al
je     11af <test_zeroblog_extract_value+0x7f>
cmp    $0x54,%al
jne    11b6 <test_zeroblog_extract_value+0x86>
mov    $0x3,%eax
cmpb   $0x68,0x1(%rsp)
jne    11e9 <test_zeroblog_extract_value+0xb9>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    -0x2(%rax,%rbx,1),%bpl
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    $0x78,%bpl
jne    11ce <test_zeroblog_extract_value+0x9e>
xor    %ecx,%ecx
cmpb   $0x74,-0x1(%rax,%rbx,1)
setne  %cl
lea    (%rcx,%rcx,4),%eax
jmp    11e9 <test_zeroblog_extract_value+0xb9>
mov    $0x1,%eax
jmp    11e9 <test_zeroblog_extract_value+0xb9>
lea    0xe60(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%eax
jmp    11e9 <test_zeroblog_extract_value+0xb9>
movsbl -0x2(%rax,%rbx,1),%edx
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x4,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [29 x i8] c"\22body\22: \22This is some text\22\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [7 x i8] c"%s\0A%c\0A\00"
define i32 @test_zeroblog_extract_value() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = call i32 @zeroblog_extract_value(i8* %6, i8* %7)
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 1, i32* %1
br label %58
14: ; preds = %0
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 84
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 2, i32* %1
br label %58
22: ; preds = %14
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 104
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 3, i32* %1
br label %58
28: ; preds = %22
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 120
br i1 %36, label %37, label %47
37: ; preds = %28
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %45)
store i32 4, i32* %1
br label %58
47: ; preds = %28
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 116
br i1 %55, label %56, label %57
56: ; preds = %47
store i32 5, i32* %1
br label %58
57: ; preds = %47
store i32 0, i32* %1
br label %58
58: ; preds = %57, %56, %37, %27, %19, %13
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"\22body\22: \22This is some text\22\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [7 x i8] c"%s\0A%c\0A\00"
define i32 @test_zeroblog_extract_value() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = call i32 @zeroblog_extract_value(i8* %3, i8* %4)
%6 = load i8, i8* %4
switch i8 %6, label %7 [
i8 0, label %35
i8 84, label %9
]
7: ; preds = %0
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %35
9: ; preds = %0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 104
br i1 %12, label %13, label %35
13: ; preds = %9
%14 = call i32 @strlen(i8* %4)
%15 = add nsw i32 %14, -2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 120
%20 = call i32 @strlen(i8* %4)
br i1 %19, label %28, label %21
21: ; preds = %13
%22 = add nsw i32 %20, -2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %26)
br label %35
28: ; preds = %13
%29 = add nsw i32 %20, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 116
%34 = select i1 %33, i32 0, i32 5
br label %35
35: ; preds = %28, %9, %0, %21, %7
%36 = phi i32 [ 2, %7 ], [ 4, %21 ], [ 1, %0 ], [ 3, %9 ], [ %34, %28 ]
ret i32 %36
}