#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 */
struct operation {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ gwkv_demarshal_client(char *, struct operation **, int *);
int test_demarshal_set(int status) {
  struct operation *set_op;
  int set_status;
  char *stored = "STORED\r\n";
  char *not_stored = "NOT_STORED\r\n";
  char *exits = "EXISTS\r\n";
  char *not_found = "NOT_FOUND\r\n";
  switch (status) {
  case 0:
    assert(gwkv_demarshal_client(stored, &set_op, &set_status) == 0);
    assert(set_status == 0);
    break;
  case 1:
    assert(gwkv_demarshal_client(not_stored, &set_op, &set_status) == 0);
    assert(set_status == 1);
    break;
  case 2:
    assert(gwkv_demarshal_client(exits, &set_op, &set_status) == 0);
    assert(set_status == 2);
    break;
  case 3:
    assert(gwkv_demarshal_client(not_found, &set_op, &set_status) == 0);
    assert(set_status == 3);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_demarshal_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    0xee2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x3,%rax
ja     1253 <test_demarshal_set+0x133>
mov    -0x40(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <gwkv_demarshal_client@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    1253 <test_demarshal_set+0x133>
mov    -0x28(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <gwkv_demarshal_client@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    1253 <test_demarshal_set+0x133>
mov    -0x30(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <gwkv_demarshal_client@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    1253 <test_demarshal_set+0x133>
mov    -0x38(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <gwkv_demarshal_client@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x3,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_demarshal_set>:
cmp    $0x3,%edi
ja     11f4 <test_demarshal_set+0xd4>
sub    $0x18,%rsp
mov    %edi,%eax
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xece(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <gwkv_demarshal_client@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
cmpl   $0x0,0xc(%rsp)
jmp    11e5 <test_demarshal_set+0xc5>
lea    0xea0(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <gwkv_demarshal_client@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
cmpl   $0x1,0xc(%rsp)
jmp    11e5 <test_demarshal_set+0xc5>
lea    0xe83(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <gwkv_demarshal_client@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
cmpl   $0x2,0xc(%rsp)
jmp    11e5 <test_demarshal_set+0xc5>
lea    0xe62(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <gwkv_demarshal_client@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
cmpl   $0x3,0xc(%rsp)
sete   %al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x18,%rsp
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.operation = type { i32 }
@.str = [9 x i8] c"STORED\0D\0A\00"
@.str.1 = [13 x i8] c"NOT_STORED\0D\0A\00"
@.str.2 = [9 x i8] c"EXISTS\0D\0A\00"
@.str.3 = [12 x i8] c"NOT_FOUND\0D\0A\00"
define i32 @test_demarshal_set(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.operation*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = load i32, i32* %2
switch i32 %9, label %50 [
i32 0, label %10
i32 1, label %20
i32 2, label %30
i32 3, label %40
]
10: ; preds = %1
%11 = load i8*, i8** %5
%12 = call i32 @gwkv_demarshal_client(i8* %11, %struct.operation** %3, i32* %4)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
br label %50
20: ; preds = %1
%21 = load i8*, i8** %6
%22 = call i32 @gwkv_demarshal_client(i8* %21, %struct.operation** %3, i32* %4)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
br label %50
30: ; preds = %1
%31 = load i8*, i8** %7
%32 = call i32 @gwkv_demarshal_client(i8* %31, %struct.operation** %3, i32* %4)
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 2
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
br label %50
40: ; preds = %1
%41 = load i8*, i8** %8
%42 = call i32 @gwkv_demarshal_client(i8* %41, %struct.operation** %3, i32* %4)
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 3
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
br label %50
50: ; preds = %1, %40, %30, %20, %10
ret i32 0
}

LLVM IR (-O2):
%struct.operation = type { i32 }
@.str = [9 x i8] c"STORED\0D\0A\00"
@.str.1 = [13 x i8] c"NOT_STORED\0D\0A\00"
@.str.2 = [9 x i8] c"EXISTS\0D\0A\00"
@.str.3 = [12 x i8] c"NOT_FOUND\0D\0A\00"
define i32 @test_demarshal_set(i32 %0) {
%2 = alloca %struct.operation*
%3 = alloca i32
%4 = bitcast %struct.operation** %2 to i8*
%5 = bitcast i32* %3 to i8*
switch i32 %0, label %38 [
i32 0, label %6
i32 1, label %13
i32 2, label %20
i32 3, label %27
]
6: ; preds = %1
%7 = call i32 @gwkv_demarshal_client(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.operation** %2, i32* %3)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br label %34
13: ; preds = %1
%14 = call i32 @gwkv_demarshal_client(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %struct.operation** %2, i32* %3)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1
br label %34
20: ; preds = %1
%21 = call i32 @gwkv_demarshal_client(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %struct.operation** %2, i32* %3)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 2
br label %34
27: ; preds = %1
%28 = call i32 @gwkv_demarshal_client(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %struct.operation** %2, i32* %3)
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 3
br label %34
34: ; preds = %6, %13, %20, %27
%35 = phi i1 [ %33, %27 ], [ %26, %20 ], [ %19, %13 ], [ %12, %6 ]
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
br label %38
38: ; preds = %34, %1
ret i32 0
}