#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*/ free(char *);
char *strdup(char *);
int system(char *);
int /*<<< orphan*/ xstrcat(char *, char const *);
int browser_Open(const char *psz_url) {
  char *psz_open_commandline;
  int i_ret;
  psz_open_commandline = strdup("www-browser");
  xstrcat(psz_open_commandline, psz_url);
  i_ret = system(psz_open_commandline);
  if (i_ret == 0)
    return 0;
  free(psz_open_commandline);
  psz_open_commandline = strdup("mozilla");
  xstrcat(psz_open_commandline, psz_url);
  return system(psz_open_commandline);
}


x86 assembly (clang, -O0):
<browser_Open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <xstrcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    118b <browser_Open+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    11bd <browser_Open+0x7d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xe71(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <xstrcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<browser_Open>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <xstrcat@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
test   %eax,%eax
je     119e <browser_Open+0x5e>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe90(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <xstrcat@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"www-browser\00"
@.str.1 = [8 x i8] c"mozilla\00"
define i32 @browser_Open(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = call i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @xstrcat(i8* %7, i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @system(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 0, i32* %2
br label %24
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = call i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = load i8*, i8** %3
%21 = call i32 @xstrcat(i8* %19, i8* %20)
%22 = load i8*, i8** %4
%23 = call i32 @system(i8* %22)
store i32 %23, i32* %2
br label %24
24: ; preds = %15, %14
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [12 x i8] c"www-browser\00"
@.str.1 = [8 x i8] c"mozilla\00"
define i32 @browser_Open(i8* %0) {
%2 = tail call dereferenceable_or_null(12) i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @xstrcat(i8* %2, i8* %0)
%4 = tail call i32 @system(i8* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = tail call i32 @free(i8* %2)
%8 = tail call dereferenceable_or_null(8) i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @xstrcat(i8* %8, i8* %0)
%10 = tail call i32 @system(i8* %8)
br label %11
11: ; preds = %1, %6
%12 = phi i32 [ %10, %6 ], [ 0, %1 ]
ret i32 %12
}