#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 */
typedef int /*<<< orphan*/ domain;

/* Variables and functions */
int /*<<< orphan*/ find_domain(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strscpy(char *, char *, int);
int resolveabsoluteURLRedirect(char url[], char redirectTo[],
                               int redirectToBufSize) {
  char domain[512];
  char newurl[512];
  if (!find_domain(url, domain, sizeof(domain))) {
    return 0;
  }
  sprintf(newurl, "http://%s%s", domain, redirectTo);
  strscpy(redirectTo, newurl, redirectToBufSize);
}


x86 assembly (clang, -O0):
<resolveabsoluteURLRedirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    $0x200,%edx
call   1030 <find_domain@plt>
cmp    $0x0,%eax
jne    1170 <resolveabsoluteURLRedirect+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <resolveabsoluteURLRedirect+0x71>
lea    -0x420(%rbp),%rdi
lea    -0x220(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe77(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <strscpy@plt>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resolveabsoluteURLRedirect>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0x200,%edx
call   1030 <find_domain@plt>
test   %eax,%eax
je     117b <resolveabsoluteURLRedirect+0x4b>
lea    0xea8(%rip),%rsi
lea    0x200(%rsp),%r14
mov    %rsp,%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <strscpy@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"http://%s%s\00"
define i32 @resolveabsoluteURLRedirect(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%12 = call i32 @find_domain(i8* %10, i8* %11, i32 512)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 0, i32* %4
br label %24
15: ; preds = %3
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %6
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%22 = load i32, i32* %7
%23 = call i32 @strscpy(i8* %20, i8* %21, i32 %22)
br label %24
24: ; preds = %15, %14
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [12 x i8] c"http://%s%s\00"
define i32 @resolveabsoluteURLRedirect(i8* %0, i8* %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%8 = call i32 @find_domain(i8* %0, i8* %6, i32 512)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %1)
%12 = call i32 @strscpy(i8* %1, i8* %7, i32 %2)
br label %13
13: ; preds = %3, %10
ret i32 0
}