#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ server;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int (*)(int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/));
int getCardSymbol(unsigned char);
unsigned char getCardValue(char);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/
recvfrom(int (*)(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/),
         char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/
sendto(int (*)(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/),
       char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int _socket, n, port;
  socklen_t client_length;
  char buffer[1];
  struct sockaddr_in server, client;
  if (argc < 3) {
    printf("Please enter a port number!\n");
    return 1;
  } else if (argc < 2) {
    printf("Please give an I.P. and port number to conenct to!\n");
    return 1;
  }
  _socket = socket(AF_INET, SOCK_STREAM, 0);
  if (_socket < 0) {
    printf("I couldn't open a new socket!\n");
    return 2;
  }
  bzero(&server, sizeof(server));
  port = atoi(argv[2]);
  if (port == 0) {
    printf("\"%s\" should be a port number!\n", argv[2]);
    return 1;
  }
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = inet_addr(argv[1]);
  server.sin_port = htons(port);
  srand(time(NULL));
  int server_sum = 0, client_sum = 0;
  unsigned short cards_used = 0;
  while (client_sum <= 21 && server_sum <= 21) {
    unsigned char card;
    do
      card = (unsigned char)(rand() % 13 + 1);
    while ((cards_used >> card) & 1 == 1);
    printf("You got a %c!\n", getCardSymbol(card));
    cards_used |= 1 << (16 - card);
    client_sum += card;
    if (client_sum > 21)
      break;
    buffer[0] = getCardSymbol(card);
    sendto(socket, buffer, 1, 0, (struct sockaddr *)&server, sizeof(server));
    int length = sizeof(server);
    recvfrom(socket, buffer, 1, 0, (struct sockaddr *)&server, &length);
    printf("The dealer got a %c!\n", buffer[0]);
    server_sum += card = getCardValue(buffer[0]);
    cards_used |= 1 << (16 - card);
  }
  if (server_sum > 21)
    printf("The dealer busted with %d!\nYOU WIN!\n", server_sum);
  else
    printf("You busted with %d!\nYou lose. :(\n", client_sum);
  close(socket);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    120a <main+0x3a>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    148d <main+0x2bd>
cmpl   $0x2,-0x8(%rbp)
jge    122e <main+0x5e>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    148d <main+0x2bd>
jmp    1233 <main+0x63>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1108 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1273 <main+0xa3>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    148d <main+0x2bd>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12bd <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    148d <main+0x2bd>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movw   $0x0,-0x4a(%rbp)
xor    %eax,%eax
cmpl   $0x15,-0x48(%rbp)
mov    %al,-0x51(%rbp)
jg     1321 <main+0x151>
cmpl   $0x15,-0x44(%rbp)
setle  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1331 <main+0x161>
jmp    1450 <main+0x280>
jmp    1336 <main+0x166>
mov    $0x0,%al
call   10f0 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%al
mov    %al,-0x4b(%rbp)
movzwl -0x4a(%rbp),%eax
movzbl -0x4b(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1336 <main+0x166>
movzbl -0x4b(%rbp),%edi
call   1030 <getCardSymbol@plt>
mov    %eax,%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movzbl -0x4b(%rbp),%eax
mov    $0x10,%ecx
sub    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
movzwl -0x4a(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4a(%rbp)
movzbl -0x4b(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x15,-0x48(%rbp)
jle    13b3 <main+0x1e3>
jmp    1450 <main+0x280>
movzbl -0x4b(%rbp),%edi
call   1030 <getCardSymbol@plt>
mov    %al,-0x21(%rbp)
lea    -0x21(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    0x2c2a(%rip),%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
movl   $0xc,-0x50(%rbp)
lea    -0x21(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    0x2c02(%rip),%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
lea    -0x50(%rbp),%r9
call   10c0 <recvfrom@plt>
movsbl -0x21(%rbp),%esi
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x21(%rbp),%edi
call   10a0 <getCardValue@plt>
mov    %al,-0x4b(%rbp)
movzbl %al,%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
movzbl -0x4b(%rbp),%eax
mov    $0x10,%ecx
sub    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
movzwl -0x4a(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4a(%rbp)
jmp    1308 <main+0x138>
cmpl   $0x15,-0x44(%rbp)
jle    1470 <main+0x2a0>
mov    -0x44(%rbp),%esi
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1481 <main+0x2b1>
mov    -0x48(%rbp),%esi
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b70(%rip),%rdi
call   1070 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jg     1209 <main+0x29>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    13e5 <main+0x205>
mov    %rsi,%rbx
mov    0x2dcd(%rip),%r15
mov    (%r15),%edi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1118 <socket@plt>
test   %eax,%eax
js     138c <main+0x1ac>
lea    0x8(%rsp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x10(%rbx),%r14
mov    %r14,%rdi
call   10f0 <atoi@plt>
test   %eax,%eax
je     139f <main+0x1bf>
mov    %eax,%ebp
mov    (%r15),%eax
mov    %eax,0x10(%rsp)
mov    0x8(%rbx),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
lea    0x8(%rsp),%r13
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
movzwl %r15w,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1100 <rand@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
add    $0x1,%al
movzbl %al,%r14d
bt     %r14d,%r12d
jb     12a0 <main+0xc0>
mov    %r14d,%edi
call   1040 <getCardSymbol@plt>
lea    0xd3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    %r14d,%ebx
cmp    $0x15,%ebx
ja     13b7 <main+0x1d7>
mov    $0x10,%al
sub    %r14b,%al
bts    %eax,%r15d
mov    %r14d,%edi
call   1040 <getCardSymbol@plt>
mov    %al,0x3(%rsp)
mov    0x2ce7(%rip),%r14
mov    %r14,%rdi
lea    0x3(%rsp),%r12
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    $0xc,%r9d
call   1070 <sendto@plt>
movl   $0xc,0x4(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r13,%r8
lea    0x4(%rsp),%r9
call   10d0 <recvfrom@plt>
movsbl 0x3(%rsp),%esi
lea    0xccf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x3(%rsp),%edi
call   10b0 <getCardValue@plt>
movzbl %al,%eax
add    %eax,%ebp
mov    $0x10,%cl
sub    %al,%cl
movzwl %r15w,%r15d
bts    %ecx,%r15d
cmp    $0x16,%ebp
jb     1290 <main+0xb0>
jmp    13bc <main+0x1dc>
lea    0xcf8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
jmp    13e5 <main+0x205>
lea    0xc5a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    13e5 <main+0x205>
cmp    $0x16,%ebp
jb     13c7 <main+0x1e7>
lea    0xc81(%rip),%rdi
mov    %ebp,%esi
jmp    13d0 <main+0x1f0>
lea    0xc9b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2c1a(%rip),%rdi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [29 x i8] c"Please enter a port number!\0A\00"
@.str.1 = [52 x i8] c"Please give an I.P. and port number to conenct to!\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [31 x i8] c"I couldn't open a new socket!\0A\00"
@.str.3 = [31 x i8] c"\22%s\22 should be a port number!\0A\00"
@.str.4 = [15 x i8] c"You got a %c!\0A\00"
@.str.5 = [22 x i8] c"The dealer got a %c!\0A\00"
@.str.6 = [37 x i8] c"The dealer busted with %d!\0AYOU WIN!\0A\00"
@.str.7 = [34 x i8] c"You busted with %d!\0AYou lose. :(\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1 x i8]
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca i32
%15 = alloca i16
%16 = alloca i8
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %144
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %144
27: ; preds = %22
br label %28
28: ; preds = %27
%29 = load i32, i32* @AF_INET
%30 = load i32, i32* @SOCK_STREAM
%31 = call i32 @socket(i32 %29, i32 %30, i32 0)
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %144
36: ; preds = %28
%37 = call i32 @bzero(%struct.sockaddr_in* %11, i32 12)
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %36
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %47)
store i32 1, i32* %3
br label %144
49: ; preds = %36
%50 = load i32, i32* @AF_INET
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %50, i32* %51
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @inet_addr(i8* %54)
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%57 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %56, i32 0, i32 0
store i32 %55, i32* %57
%58 = load i32, i32* %8
%59 = call i32 @htons(i32 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %59, i32* %60
%61 = call i32 @time(i32* null)
%62 = call i32 @srand(i32 %61)
store i32 0, i32* %13
store i32 0, i32* %14
store i16 0, i16* %15
br label %63
63: ; preds = %104, %49
%64 = load i32, i32* %14
%65 = icmp sle i32 %64, 21
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32, i32* %13
%68 = icmp sle i32 %67, 21
br label %69
69: ; preds = %66, %63
%70 = phi i1 [ false, %63 ], [ %68, %66 ]
br i1 %70, label %71, label %133
71: ; preds = %69
br label %72
72: ; preds = %77, %71
%73 = call i32 (...) @rand()
%74 = srem i32 %73, 13
%75 = add nsw i32 %74, 1
%76 = trunc i32 %75 to i8
store i8 %76, i8* %16
br label %77
77: ; preds = %72
%78 = load i16, i16* %15
%79 = zext i16 %78 to i32
%80 = load i8, i8* %16
%81 = zext i8 %80 to i32
%82 = ashr i32 %79, %81
%83 = and i32 %82, 1
%84 = icmp ne i32 %83, 0
br i1 %84, label %72, label %85
85: ; preds = %77
%86 = load i8, i8* %16
%87 = call i32 @getCardSymbol(i8 zeroext %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %87)
%89 = load i8, i8* %16
%90 = zext i8 %89 to i32
%91 = sub nsw i32 16, %90
%92 = shl i32 1, %91
%93 = load i16, i16* %15
%94 = zext i16 %93 to i32
%95 = or i32 %94, %92
%96 = trunc i32 %95 to i16
store i16 %96, i16* %15
%97 = load i8, i8* %16
%98 = zext i8 %97 to i32
%99 = load i32, i32* %14
%100 = add nsw i32 %99, %98
store i32 %100, i32* %14
%101 = load i32, i32* %14
%102 = icmp sgt i32 %101, 21
br i1 %102, label %103, label %104
103: ; preds = %85
br label %133
104: ; preds = %85
%105 = load i8, i8* %16
%106 = call i32 @getCardSymbol(i8 zeroext %105)
%107 = trunc i32 %106 to i8
%108 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
store i8 %107, i8* %108
%109 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%110 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%111 = call i32 @sendto(i32 (i32, i32, i32)* @socket, i8* %109, i32 1, i32 0, %struct.sockaddr* %110, i32 12)
store i32 12, i32* %17
%112 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%113 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%114 = call i32 @recvfrom(i32 (i32, i32, i32)* @socket, i8* %112, i32 1, i32 0, %struct.sockaddr* %113, i32* %17)
%115 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %117)
%119 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%120 = load i8, i8* %119
%121 = call zeroext i8 @getCardValue(i8 signext %120)
store i8 %121, i8* %16
%122 = zext i8 %121 to i32
%123 = load i32, i32* %13
%124 = add nsw i32 %123, %122
store i32 %124, i32* %13
%125 = load i8, i8* %16
%126 = zext i8 %125 to i32
%127 = sub nsw i32 16, %126
%128 = shl i32 1, %127
%129 = load i16, i16* %15
%130 = zext i16 %129 to i32
%131 = or i32 %130, %128
%132 = trunc i32 %131 to i16
store i16 %132, i16* %15
br label %63
133: ; preds = %103, %69
%134 = load i32, i32* %13
%135 = icmp sgt i32 %134, 21
br i1 %135, label %136, label %139
136: ; preds = %133
%137 = load i32, i32* %13
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %137)
br label %142
139: ; preds = %133
%140 = load i32, i32* %14
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %140)
br label %142
142: ; preds = %139, %136
%143 = call i32 @close(i32 (i32, i32, i32)* @socket)
br label %144
144: ; preds = %142, %44, %34, %25, %20
%145 = load i32, i32* %3
ret i32 %145
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [31 x i8] c"\22%s\22 should be a port number!\0A\00"
@.str.4 = [15 x i8] c"You got a %c!\0A\00"
@.str.5 = [22 x i8] c"The dealer got a %c!\0A\00"
@.str.6 = [37 x i8] c"The dealer busted with %d!\0AYOU WIN!\0A\00"
@.str.7 = [34 x i8] c"You busted with %d!\0AYou lose. :(\0A\00"
@str = [30 x i8] c"I couldn't open a new socket!\00"
@str.8 = [28 x i8] c"Please enter a port number!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = icmp slt i32 %0, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
br label %87
11: ; preds = %2
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %87
18: ; preds = %11
%19 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %87
26: ; preds = %18
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i32 @inet_addr(i8* %30)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %31, i32* %32
%33 = tail call i32 @htons(i32 %22)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %33, i32* %34
%35 = tail call i32 @time(i32* null)
%36 = tail call i32 @srand(i32 %35)
%37 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%38 = bitcast i32* %5 to i8*
br label %39
39: ; preds = %26, %58
%40 = phi i32 [ 0, %26 ], [ %76, %58 ]
%41 = phi i32 [ 0, %26 ], [ %56, %58 ]
%42 = phi i32 [ 0, %26 ], [ %72, %58 ]
%43 = and i32 %40, 65535
br label %44
44: ; preds = %39, %44
%45 = call i32 (...) @rand()
%46 = srem i32 %45, 13
%47 = trunc i32 %46 to i8
%48 = add nsw i8 %47, 1
%49 = zext i8 %48 to i32
%50 = shl nuw i32 1, %49
%51 = and i32 %43, %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %44
53: ; preds = %44
%54 = call i32 @getCardSymbol(i8 zeroext %48)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i32 %41, %49
%57 = icmp ugt i32 %56, 21
br i1 %57, label %78, label %58
58: ; preds = %53
%59 = sub nsw i32 16, %49
%60 = shl nuw nsw i32 1, %59
%61 = or i32 %60, %40
%62 = call i32 @getCardSymbol(i8 zeroext %48)
%63 = trunc i32 %62 to i8
store i8 %63, i8* %6
%64 = call i32 @sendto(i32 (i32, i32, i32)* @socket, i8* %6, i32 1, i32 0, %struct.sockaddr* %37, i32 12)
store i32 12, i32* %5
%65 = call i32 @recvfrom(i32 (i32, i32, i32)* @socket, i8* %6, i32 1, i32 0, %struct.sockaddr* %37, i32* %5)
%66 = load i8, i8* %6
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %67)
%69 = load i8, i8* %6
%70 = call zeroext i8 @getCardValue(i8 signext %69)
%71 = zext i8 %70 to i32
%72 = add nuw nsw i32 %42, %71
%73 = sub nsw i32 16, %71
%74 = shl nuw nsw i32 1, %73
%75 = and i32 %61, 65535
%76 = or i32 %74, %75
%77 = icmp ult i32 %72, 22
br i1 %77, label %39, label %80
78: ; preds = %53
%79 = icmp ugt i32 %42, 21
br i1 %79, label %80, label %83
80: ; preds = %58, %78
%81 = phi i32 [ %42, %78 ], [ %72, %58 ]
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %81)
br label %85
83: ; preds = %78
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %56)
br label %85
85: ; preds = %83, %80
%86 = call i32 @close(i32 (i32, i32, i32)* @socket)
br label %87
87: ; preds = %85, %24, %16, %9
%88 = phi i32 [ 1, %9 ], [ 2, %16 ], [ 1, %24 ], [ 0, %85 ]
ret i32 %88
}