#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*/ strlen(char *);
int write(int, char *, int);
int save_url(void *url, void *ctx) {
  int *fd = ctx;
  int n = 0;
  if (!url)
    return -1;
  n = write(*fd, url, strlen((char *)url));
  n += write(*fd, "\n", 1);
  return n;
}


x86 assembly (clang, -O0):
<save_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <save_url+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <save_url+0x84>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_url>:
test   %rdi,%rdi
je     115f <save_url+0x3f>
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%ebp
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%ebx
mov    (%r14),%edi
lea    0xeb2(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @save_url(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i32 -1, i32* %3
br label %26
13: ; preds = %2
%14 = load i32*, i32** %6
%15 = load i32, i32* %14
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @write(i32 %15, i8* %16, i32 %18)
store i32 %19, i32* %7
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%23 = load i32, i32* %7
%24 = add nsw i32 %23, %22
store i32 %24, i32* %7
%25 = load i32, i32* %7
store i32 %25, i32* %3
br label %26
26: ; preds = %13, %12
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i32 @save_url(i8* %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
%4 = icmp eq i8* %0, null
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = load i32, i32* %3
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @write(i32 %6, i8* %0, i32 %7)
%9 = load i32, i32* %3
%10 = tail call i32 @write(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%11 = add nsw i32 %10, %8
br label %12
12: ; preds = %2, %5
%13 = phi i32 [ %11, %5 ], [ -1, %2 ]
ret i32 %13
}