#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 get_ticker();
scalar_t__ lw_sock_send_str_ex(int *, char *);
int lw_sock_send_str(int *sock, char *str) {
  int result = 0;
  int limit_ticker;
  limit_ticker = get_ticker() + 15000;
  while (limit_ticker > get_ticker() && !result && *sock >= 0) {
    if (lw_sock_send_str_ex(sock, str)) {
      result = 1;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<lw_sock_send_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <get_ticker@plt>
add    $0x3a98,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <get_ticker@plt>
mov    -0x20(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
jle    1181 <lw_sock_send_str+0x61>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jne    1181 <lw_sock_send_str+0x61>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
setge  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1191 <lw_sock_send_str+0x71>
jmp    11b4 <lw_sock_send_str+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <lw_sock_send_str_ex@plt>
cmp    $0x0,%rax
je     11af <lw_sock_send_str+0x8f>
movl   $0x1,-0x14(%rbp)
jmp    1146 <lw_sock_send_str+0x26>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lw_sock_send_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <get_ticker@plt>
mov    %eax,%r12d
add    $0x3a98,%r12d
xor    %eax,%eax
call   1040 <get_ticker@plt>
cmp    %eax,%r12d
jle    118e <lw_sock_send_str+0x6e>
cmpl   $0x0,(%rbx)
js     118e <lw_sock_send_str+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <lw_sock_send_str_ex@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1040 <get_ticker@plt>
test   %rbp,%rbp
jne    1184 <lw_sock_send_str+0x64>
cmp    %eax,%r12d
jle    1184 <lw_sock_send_str+0x64>
cmpl   $0x0,(%rbx)
jns    1160 <lw_sock_send_str+0x40>
xor    %r15d,%r15d
test   %rbp,%rbp
setne  %r15b
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lw_sock_send_str(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%7 = call i32 (...) @get_ticker()
%8 = add nsw i32 %7, 15000
store i32 %8, i32* %6
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %6
%11 = call i32 (...) @get_ticker()
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = load i32, i32* %17
%19 = icmp sge i32 %18, 0
br label %20
20: ; preds = %16, %13, %9
%21 = phi i1 [ false, %13 ], [ false, %9 ], [ %19, %16 ]
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = load i32*, i32** %3
%24 = load i8*, i8** %4
%25 = call i64 @lw_sock_send_str_ex(i32* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 1, i32* %5
br label %28
28: ; preds = %27, %22
br label %9
29: ; preds = %20
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
define i32 @lw_sock_send_str(i32* %0, i8* %1) {
%3 = tail call i32 (...) @get_ticker()
%4 = add nsw i32 %3, 15000
%5 = tail call i32 (...) @get_ticker()
%6 = icmp sgt i32 %4, %5
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = load i32, i32* %0
%9 = icmp sgt i32 %8, -1
br i1 %9, label %13, label %21
10: ; preds = %13
%11 = load i32, i32* %0
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %19
13: ; preds = %7, %10
%14 = tail call i64 @lw_sock_send_str_ex(i32* %0, i8* %1)
%15 = icmp ne i64 %14, 0
%16 = tail call i32 (...) @get_ticker()
%17 = icmp sle i32 %4, %16
%18 = or i1 %15, %17
br i1 %18, label %19, label %10
19: ; preds = %13, %10
%20 = zext i1 %15 to i32
br label %21
21: ; preds = %7, %19, %2
%22 = phi i32 [ 0, %2 ], [ 0, %7 ], [ %20, %19 ]
ret i32 %22
}