#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 findProcess(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ system(char *);
int mount(char *url, char *user, char *passwd) {
  int r;
  char str[512];
  char *str1 =
      "<html><title>NetAudio</title><LINK href=/mpd.css "
      "rel=stylesheet>\r\n<script>function "
      "hello(){document.getElementById('scrap').style.display = "
      "'none';}</script><body onLoad=hello();>\r\n<br><center><a class=lnk "
      "href='/cgi-bin/csamba.cgi'>Check Samba Status</a></center>\r\n<div "
      "id=scrap style='position:absolute; z-index:-1000;top:1px; left:1px; "
      "width:0px; height:0px;visibility=hidden;'>\r\n</div>";
  char *str2 = "<center><br>Samba Mount : "
               "Done...<br></center>\r\n<br></center></body></html>";
  char *str3 = "<center><br>Samba Mount : "
               "Failed.<br></center>\r\n<br></center></body></html>";
  printf("%s\r\n", str1);
  if (user == NULL && passwd == NULL)
    printf("QUERY_STRING : Failed, Reload the Image");
  else {
    sprintf(str, "smbmount %s /mnt -o %s,%s", url, user, passwd);
    system(str);
  }
  r = findProcess("smbmount_child");
  if (r != -1)
    printf("%s\r\n", str2);
  else
    printf("%s\r\n", str3);
  return 0;
}


x86 assembly (clang, -O0):
<mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x228(%rbp)
lea    0x101a(%rip),%rax
mov    %rax,-0x230(%rbp)
lea    0x1058(%rip),%rax
mov    %rax,-0x238(%rbp)
mov    -0x228(%rbp),%rsi
lea    0x108f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11bf <mount+0x7f>
cmpq   $0x0,-0x18(%rbp)
jne    11bf <mount+0x7f>
lea    0x1070(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ea <mount+0xaa>
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0x1072(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <system@plt>
lea    0x1074(%rip),%rdi
call   1050 <findProcess@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     121d <mount+0xdd>
mov    -0x230(%rbp),%rsi
lea    0x100d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1232 <mount+0xf2>
mov    -0x238(%rbp),%rsi
lea    0xff3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x10c0(%rip),%rdi
lea    0xe9b(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rax
or     %r14,%rax
jne    1184 <mount+0x44>
lea    0x10a8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a7 <mount+0x67>
lea    0x10c0(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1060 <sprintf@plt>
mov    %r12,%rdi
call   1030 <system@plt>
lea    0x10b7(%rip),%rdi
call   1050 <findProcess@plt>
cmp    $0xffffffff,%eax
lea    0x1015(%rip),%rax
lea    0xfc2(%rip),%rsi
cmove  %rax,%rsi
lea    0x104f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [390 x i8] c"<html><title>NetAudio</title><LINK href=/mpd.css rel=stylesheet>\0D\0A<script>function hello(){document.getElementById('scrap').style.display = 'none';}</script><body onLoad=hello();>\0D\0A<br><center><a class=lnk href='/cgi-bin/csamba.cgi'>Check Samba Status</a></center>\0D\0A<div id=scrap style='position:absolute; z-index:-1000;top:1px; left:1px; width:0px; height:0px;visibility=hidden;'>\0D\0A</div>\00"
@.str.1 = [76 x i8] c"<center><br>Samba Mount : Done...<br></center>\0D\0A<br></center></body></html>\00"
@.str.2 = [76 x i8] c"<center><br>Samba Mount : Failed.<br></center>\0D\0A<br></center></body></html>\00"
@.str.3 = [5 x i8] c"%s\0D\0A\00"
@.str.4 = [40 x i8] c"QUERY_STRING : Failed, Reload the Image\00"
@.str.5 = [26 x i8] c"smbmount %s /mnt -o %s,%s\00"
@.str.6 = [15 x i8] c"smbmount_child\00"
define i32 @mount(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [512 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([390 x i8], [390 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = load i8*, i8** %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %29
21: ; preds = %16, %3
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %23, i8* %24, i8* %25)
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%28 = call i32 @system(i8* %27)
br label %29
29: ; preds = %21, %19
%30 = call i32 @findProcess(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %39
36: ; preds = %29
%37 = load i8*, i8** %11
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
ret i32 0
}

LLVM IR (-O2):
@.str = [390 x i8] c"<html><title>NetAudio</title><LINK href=/mpd.css rel=stylesheet>\0D\0A<script>function hello(){document.getElementById('scrap').style.display = 'none';}</script><body onLoad=hello();>\0D\0A<br><center><a class=lnk href='/cgi-bin/csamba.cgi'>Check Samba Status</a></center>\0D\0A<div id=scrap style='position:absolute; z-index:-1000;top:1px; left:1px; width:0px; height:0px;visibility=hidden;'>\0D\0A</div>\00"
@.str.1 = [76 x i8] c"<center><br>Samba Mount : Done...<br></center>\0D\0A<br></center></body></html>\00"
@.str.2 = [76 x i8] c"<center><br>Samba Mount : Failed.<br></center>\0D\0A<br></center></body></html>\00"
@.str.3 = [5 x i8] c"%s\0D\0A\00"
@.str.4 = [40 x i8] c"QUERY_STRING : Failed, Reload the Image\00"
@.str.5 = [26 x i8] c"smbmount %s /mnt -o %s,%s\00"
@.str.6 = [15 x i8] c"smbmount_child\00"
define i32 @mount(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([390 x i8], [390 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %1, null
%8 = icmp eq i8* %2, null
%9 = and i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %15
12: ; preds = %3
%13 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
%14 = call i32 @system(i8* %5)
br label %15
15: ; preds = %12, %10
%16 = tail call i32 @findProcess(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i32 %16, -1
%18 = select i1 %17, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %18)
ret i32 0
}