#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int unban_ip() {
  char bgp_message[256];
  char *ip_cidr_form = "10.10.10.123/32";
  int exabgp_pipe = open("/var/run/exabgp.cmd", O_WRONLY);
  if (exabgp_pipe <= 0) {
    printf("Can't open exabgp PIPE");
    exit(1);
  }
  char *action = "withdraw";
  sprintf(bgp_message, "%s route %s\n", action, ip_cidr_form);
  int wrote_bytes = write(exabgp_pipe, bgp_message, strlen(bgp_message));
  printf("We wrote %d bytes\n", wrote_bytes);
  close(exabgp_pipe);
}


x86 assembly (clang, -O0):
<unban_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
lea    0xe7e(%rip),%rax
mov    %rax,-0x118(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    0xe77(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x11c(%rbp)
cmpl   $0x0,-0x11c(%rbp)
jg     11c9 <unban_ip+0x59>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe6b(%rip),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x128(%rbp),%rdx
mov    -0x118(%rbp),%rcx
lea    0xe51(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x11c(%rbp),%eax
mov    %eax,-0x13c(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x12c(%rbp),%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x11c(%rbp),%edi
call   1060 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unban_ip>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
lea    0xe86(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
jle    11eb <unban_ip+0x7b>
mov    %eax,%ebx
lea    0xea8(%rip),%rsi
lea    0xe98(%rip),%rdx
lea    0xe56(%rip),%rcx
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <sprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <close@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"10.10.10.123/32\00"
@.str.1 = [20 x i8] c"/var/run/exabgp.cmd\00"
@O_WRONLY = global i32 0
@.str.2 = [23 x i8] c"Can't open exabgp PIPE\00"
@.str.3 = [9 x i8] c"withdraw\00"
@.str.4 = [13 x i8] c"%s route %s\0A\00"
@.str.5 = [19 x i8] c"We wrote %d bytes\0A\00"
define i32 @unban_ip() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %5
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = load i8*, i8** %3
%18 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %16, i8* %17)
%19 = load i32, i32* %4
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = call i32 @write(i32 %19, i8* %20, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %4
%27 = call i32 @close(i32 %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [16 x i8] c"10.10.10.123/32\00"
@.str.1 = [20 x i8] c"/var/run/exabgp.cmd\00"
@O_WRONLY = global i32 0
@.str.2 = [23 x i8] c"Can't open exabgp PIPE\00"
@.str.3 = [9 x i8] c"withdraw\00"
@.str.4 = [13 x i8] c"%s route %s\0A\00"
@.str.5 = [19 x i8] c"We wrote %d bytes\0A\00"
define i32 @unban_ip() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @strlen(i8* %2)
%12 = call i32 @write(i32 %4, i8* %2, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = call i32 @close(i32 %4)
ret i32 undef
}