#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 atoi(char *);
int /*<<< orphan*/ perror(char *);
int write(int, char *, int);
char check_args(int ac, char *av, int *p) {
  if (!av || ac != 3 || !(*p = atoi(av))) {
    if (write(2, "usage: ./client server-ip port\n", 31) == -1)
      perror("write");
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<check_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1170 <check_args+0x40>
cmpl   $0x3,-0x8(%rbp)
jne    1170 <check_args+0x40>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x18(%rbp),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
jne    11a4 <check_args+0x74>
mov    $0x2,%edi
lea    0xe84(%rip),%rsi
mov    $0x1f,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    119b <check_args+0x6b>
lea    0xe8a(%rip),%rdi
call   1040 <perror@plt>
movb   $0x1,-0x1(%rbp)
jmp    11a8 <check_args+0x78>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_args>:
push   %rbx
cmp    $0x3,%edi
jne    1150 <check_args+0x20>
test   %rsi,%rsi
je     1150 <check_args+0x20>
mov    %rdx,%rbx
mov    %rsi,%rdi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
test   %eax,%eax
je     1150 <check_args+0x20>
xor    %ebx,%ebx
jmp    116d <check_args+0x3d>
lea    0xea9(%rip),%rsi
mov    $0x2,%edi
mov    $0x1f,%edx
call   1030 <write@plt>
mov    $0x1,%bl
cmp    $0xffffffff,%eax
je     1171 <check_args+0x41>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xea8(%rip),%rdi
call   1040 <perror@plt>
jmp    116d <check_args+0x3d>

LLVM IR (-O0):
@.str = [32 x i8] c"usage: ./client server-ip port\0A\00"
@.str.1 = [6 x i8] c"write\00"
define signext i8 @check_args(i32 %0, i8* %1, i32* %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 3
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = call i32 @atoi(i8* %14)
%16 = load i32*, i32** %7
store i32 %15, i32* %16
%17 = icmp ne i32 %15, 0
br i1 %17, label %24, label %18
18: ; preds = %13, %10, %3
%19 = call i32 @write(i32 2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 31)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
store i8 1, i8* %4
br label %25
24: ; preds = %13
store i8 0, i8* %4
br label %25
25: ; preds = %24, %23
%26 = load i8, i8* %4
ret i8 %26
}

LLVM IR (-O2):
@.str = [32 x i8] c"usage: ./client server-ip port\0A\00"
@.str.1 = [6 x i8] c"write\00"
define signext i8 @check_args(i32 %0, i8* %1, i32* nocapture writeonly %2) {
%4 = icmp eq i8* %1, null
%5 = icmp ne i32 %0, 3
%6 = or i1 %5, %4
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @atoi(i8* %1)
store i32 %8, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7, %3
%11 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 31)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %7, %10, %13
%16 = phi i8 [ 1, %13 ], [ 1, %10 ], [ 0, %7 ]
ret i8 %16
}