#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 network_status {
  int dummy;
};
struct keypair {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ attacker();
int /*<<< orphan*/ increment_and_send_nonce(struct network_status *);
struct network_status *network_bind_and_accept(int);
struct network_status *network_connect(char *, int);
int /*<<< orphan*/ network_disconnect(struct network_status *);
int random_int_();
int /*<<< orphan*/ send_asymmetric_decrypted(struct network_status *,
                                             struct keypair *);
int /*<<< orphan*/ send_asymmetric_encrypted(struct network_status *,
                                             struct keypair *);
int /*<<< orphan*/ send_asymmetric_signature(struct network_status *,
                                             struct keypair *);
int /*<<< orphan*/ send_data(struct network_status *);
int /*<<< orphan*/ send_hmac(struct network_status *, struct keypair *);
int /*<<< orphan*/ send_keys(struct network_status *, struct keypair *);
int /*<<< orphan*/ send_nonce(struct network_status *);
int /*<<< orphan*/ send_pair_composed(struct network_status *);
int /*<<< orphan*/ send_pair_decomposed(struct network_status *);
int /*<<< orphan*/ send_symmetric_decrypted(struct network_status *,
                                            struct keypair *);
int /*<<< orphan*/ send_symmetric_encrypted(struct network_status *,
                                            struct keypair *);
void symbolic_attacker(int attacker_id, struct keypair *keypair) {
  for (;;) {
    struct network_status *net_stat = 0;
    int net_choise = random_int_();
    int port = random_int_();
    if (net_choise % 2 == 0)
      net_stat = network_bind_and_accept(port % 65536);
    else
      net_stat = network_connect("localhost", port % 65536);
    {
      int action = random_int_();
      int *counter;
      switch (action % 13) {
      case 0:
        attacker();
        break;
      case 1:
        send_data(net_stat);
        break;
      case 2:
        send_pair_composed(net_stat);
        break;
      case 3:
        send_pair_decomposed(net_stat);
        break;
      case 4:
        send_nonce(net_stat);
        break;
      case 5:
        increment_and_send_nonce(net_stat);
        break;
      case 6:
        send_keys(net_stat, keypair);
        break;
      case 7:
        send_hmac(net_stat, keypair);
        break;
      case 8:
        send_symmetric_encrypted(net_stat, keypair);
        break;
      case 9:
        send_symmetric_decrypted(net_stat, keypair);
        break;
      case 10:
        send_asymmetric_encrypted(net_stat, keypair);
        break;
      case 11:
        send_asymmetric_decrypted(net_stat, keypair);
        break;
      case 12:
        send_asymmetric_signature(net_stat, keypair);
      }
    }
    network_disconnect(net_stat);
  }
}


x86 assembly (clang, -O0):
<symbolic_attacker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1090 <random_int_@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1090 <random_int_@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    126a <symbolic_attacker+0x5a>
mov    -0x20(%rbp),%eax
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10d0 <network_bind_and_accept@plt>
mov    %rax,-0x18(%rbp)
jmp    1287 <symbolic_attacker+0x77>
mov    -0x20(%rbp),%eax
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xdb6(%rip),%rdi
call   1110 <network_connect@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
call   1090 <random_int_@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rcx
mov    %ecx,%eax
imul   $0x4ec4ec4f,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%esi
mov    %esi,%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0xc,%eax
ja     13a5 <symbolic_attacker+0x195>
mov    -0x38(%rbp),%rax
lea    0xd2f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10c0 <attacker@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
call   10b0 <send_data@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
call   1120 <send_pair_composed@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
call   10f0 <send_pair_decomposed@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
call   1080 <send_nonce@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
call   1060 <increment_and_send_nonce@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <send_keys@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <send_hmac@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <send_symmetric_encrypted@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <send_symmetric_decrypted@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1100 <send_asymmetric_encrypted@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <send_asymmetric_decrypted@plt>
jmp    13a5 <symbolic_attacker+0x195>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1130 <send_asymmetric_signature@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <network_disconnect@plt>
jmp    121f <symbolic_attacker+0xf>

x86 assembly (clang, -O2):
<symbolic_attacker>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
lea    0xdde(%rip),%r12
lea    0xe0b(%rip),%r14
jmp    1248 <symbolic_attacker+0x38>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1130 <send_asymmetric_signature@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10e0 <network_disconnect@plt>
xor    %eax,%eax
call   1090 <random_int_@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <random_int_@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
sub    %ecx,%eax
test   $0x1,%bl
jne    1280 <symbolic_attacker+0x70>
mov    %eax,%edi
call   10d0 <network_bind_and_accept@plt>
jmp    128a <symbolic_attacker+0x7a>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %eax,%esi
call   1110 <network_connect@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <random_int_@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
cmp    $0xc,%eax
ja     1240 <symbolic_attacker+0x30>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   10c0 <attacker@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
call   10b0 <send_data@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
call   1120 <send_pair_composed@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
call   10f0 <send_pair_decomposed@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
call   1080 <send_nonce@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
call   1060 <increment_and_send_nonce@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <send_keys@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <send_hmac@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <send_symmetric_encrypted@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <send_symmetric_decrypted@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1100 <send_asymmetric_encrypted@plt>
jmp    1240 <symbolic_attacker+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <send_asymmetric_decrypted@plt>
jmp    1240 <symbolic_attacker+0x30>

LLVM IR (-O0):
%struct.keypair = type { i32 }
%struct.network_status = type { i32 }
@.str = [10 x i8] c"localhost\00"
define void @symbolic_attacker(i32 %0, %struct.keypair* %1) {
%3 = alloca i32
%4 = alloca %struct.keypair*
%5 = alloca %struct.network_status*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %3
store %struct.keypair* %1, %struct.keypair** %4
br label %10
10: ; preds = %73, %2
store %struct.network_status* null, %struct.network_status** %5
%11 = call i32 (...) @random_int_()
store i32 %11, i32* %6
%12 = call i32 (...) @random_int_()
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* %7
%18 = srem i32 %17, 65536
%19 = call %struct.network_status* @network_bind_and_accept(i32 %18)
store %struct.network_status* %19, %struct.network_status** %5
br label %24
20: ; preds = %10
%21 = load i32, i32* %7
%22 = srem i32 %21, 65536
%23 = call %struct.network_status* @network_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22)
store %struct.network_status* %23, %struct.network_status** %5
br label %24
24: ; preds = %20, %16
%25 = call i32 (...) @random_int_()
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = srem i32 %26, 13
switch i32 %27, label %73 [
i32 0, label %28
i32 1, label %30
i32 2, label %33
i32 3, label %36
i32 4, label %39
i32 5, label %42
i32 6, label %45
i32 7, label %49
i32 8, label %53
i32 9, label %57
i32 10, label %61
i32 11, label %65
i32 12, label %69
]
28: ; preds = %24
%29 = call i32 (...) @attacker()
br label %73
30: ; preds = %24
%31 = load %struct.network_status*, %struct.network_status** %5
%32 = call i32 @send_data(%struct.network_status* %31)
br label %73
33: ; preds = %24
%34 = load %struct.network_status*, %struct.network_status** %5
%35 = call i32 @send_pair_composed(%struct.network_status* %34)
br label %73
36: ; preds = %24
%37 = load %struct.network_status*, %struct.network_status** %5
%38 = call i32 @send_pair_decomposed(%struct.network_status* %37)
br label %73
39: ; preds = %24
%40 = load %struct.network_status*, %struct.network_status** %5
%41 = call i32 @send_nonce(%struct.network_status* %40)
br label %73
42: ; preds = %24
%43 = load %struct.network_status*, %struct.network_status** %5
%44 = call i32 @increment_and_send_nonce(%struct.network_status* %43)
br label %73
45: ; preds = %24
%46 = load %struct.network_status*, %struct.network_status** %5
%47 = load %struct.keypair*, %struct.keypair** %4
%48 = call i32 @send_keys(%struct.network_status* %46, %struct.keypair* %47)
br label %73
49: ; preds = %24
%50 = load %struct.network_status*, %struct.network_status** %5
%51 = load %struct.keypair*, %struct.keypair** %4
%52 = call i32 @send_hmac(%struct.network_status* %50, %struct.keypair* %51)
br label %73
53: ; preds = %24
%54 = load %struct.network_status*, %struct.network_status** %5
%55 = load %struct.keypair*, %struct.keypair** %4
%56 = call i32 @send_symmetric_encrypted(%struct.network_status* %54, %struct.keypair* %55)
br label %73
57: ; preds = %24
%58 = load %struct.network_status*, %struct.network_status** %5
%59 = load %struct.keypair*, %struct.keypair** %4
%60 = call i32 @send_symmetric_decrypted(%struct.network_status* %58, %struct.keypair* %59)
br label %73
61: ; preds = %24
%62 = load %struct.network_status*, %struct.network_status** %5
%63 = load %struct.keypair*, %struct.keypair** %4
%64 = call i32 @send_asymmetric_encrypted(%struct.network_status* %62, %struct.keypair* %63)
br label %73
65: ; preds = %24
%66 = load %struct.network_status*, %struct.network_status** %5
%67 = load %struct.keypair*, %struct.keypair** %4
%68 = call i32 @send_asymmetric_decrypted(%struct.network_status* %66, %struct.keypair* %67)
br label %73
69: ; preds = %24
%70 = load %struct.network_status*, %struct.network_status** %5
%71 = load %struct.keypair*, %struct.keypair** %4
%72 = call i32 @send_asymmetric_signature(%struct.network_status* %70, %struct.keypair* %71)
br label %73
73: ; preds = %69, %24, %65, %61, %57, %53, %49, %45, %42, %39, %36, %33, %30, %28
%74 = load %struct.network_status*, %struct.network_status** %5
%75 = call i32 @network_disconnect(%struct.network_status* %74)
br label %10
}

LLVM IR (-O2):
%struct.keypair = type { i32 }
%struct.network_status = type { i32 }
@.str = [10 x i8] c"localhost\00"
define void @symbolic_attacker(i32 %0, %struct.keypair* %1) {
br label %3
3: ; preds = %43, %2
%4 = tail call i32 (...) @random_int_()
%5 = tail call i32 (...) @random_int_()
%6 = and i32 %4, 1
%7 = icmp eq i32 %6, 0
%8 = srem i32 %5, 65536
br i1 %7, label %9, label %11
9: ; preds = %3
%10 = tail call %struct.network_status* @network_bind_and_accept(i32 %8)
br label %13
11: ; preds = %3
%12 = tail call %struct.network_status* @network_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %13
13: ; preds = %11, %9
%14 = phi %struct.network_status* [ %10, %9 ], [ %12, %11 ]
%15 = tail call i32 (...) @random_int_()
%16 = srem i32 %15, 13
switch i32 %16, label %43 [
i32 0, label %17
i32 1, label %19
i32 2, label %21
i32 3, label %23
i32 4, label %25
i32 5, label %27
i32 6, label %29
i32 7, label %31
i32 8, label %33
i32 9, label %35
i32 10, label %37
i32 11, label %39
i32 12, label %41
]
17: ; preds = %13
%18 = tail call i32 (...) @attacker()
br label %43
19: ; preds = %13
%20 = tail call i32 @send_data(%struct.network_status* %14)
br label %43
21: ; preds = %13
%22 = tail call i32 @send_pair_composed(%struct.network_status* %14)
br label %43
23: ; preds = %13
%24 = tail call i32 @send_pair_decomposed(%struct.network_status* %14)
br label %43
25: ; preds = %13
%26 = tail call i32 @send_nonce(%struct.network_status* %14)
br label %43
27: ; preds = %13
%28 = tail call i32 @increment_and_send_nonce(%struct.network_status* %14)
br label %43
29: ; preds = %13
%30 = tail call i32 @send_keys(%struct.network_status* %14, %struct.keypair* %1)
br label %43
31: ; preds = %13
%32 = tail call i32 @send_hmac(%struct.network_status* %14, %struct.keypair* %1)
br label %43
33: ; preds = %13
%34 = tail call i32 @send_symmetric_encrypted(%struct.network_status* %14, %struct.keypair* %1)
br label %43
35: ; preds = %13
%36 = tail call i32 @send_symmetric_decrypted(%struct.network_status* %14, %struct.keypair* %1)
br label %43
37: ; preds = %13
%38 = tail call i32 @send_asymmetric_encrypted(%struct.network_status* %14, %struct.keypair* %1)
br label %43
39: ; preds = %13
%40 = tail call i32 @send_asymmetric_decrypted(%struct.network_status* %14, %struct.keypair* %1)
br label %43
41: ; preds = %13
%42 = tail call i32 @send_asymmetric_signature(%struct.network_status* %14, %struct.keypair* %1)
br label %43
43: ; preds = %41, %13, %39, %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %17
%44 = tail call i32 @network_disconnect(%struct.network_status* %14)
br label %3
}