#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*/ sprintf(char *, char *, char *, char *, char *);
char *strrchr(char *, char);
int system(char *);
int http_rman(char *url) {
  char *pName;
  char *pSection;
  char buf[200];
  pSection = strrchr(url, '?');
  if (!pSection) {
    return -1;
  }
  pName = pSection - 1;
  *pSection++ = '\0';
  pName = strrchr(url, '?');
  if (!pName) {
    pName = pSection;
    pSection = "";
  } else
    pName++;
  sprintf(buf, "man %s %s | rman -r \"man?%%s?%%s\" -n %s -f html", pSection,
          pName, pName);
  return system(buf);
}


x86 assembly (clang, -O0):
<http_rman>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1168 <http_rman+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <http_rman+0xc5>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11bb <http_rman+0x8b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe7d(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c7 <http_rman+0x97>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe1f(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0xf0(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_rman>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,%r14
mov    $0x3f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1198 <http_rman+0x68>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    $0x3f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
lea    0xeba(%rip),%rdx
cmovne %rbx,%rdx
lea    0xe80(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rcx,%r8
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
jmp    119d <http_rman+0x6d>
mov    $0xffffffff,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [48 x i8] c"man %s %s | rman -r \22man?%%s?%%s\22 -n %s -f html\00"
define i32 @http_rman(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [200 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @strrchr(i8* %7, i8 signext 63)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 -1, i32* %2
br label %34
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 -1
store i8* %14, i8** %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
store i8 0, i8* %15
%17 = load i8*, i8** %3
%18 = call i8* @strrchr(i8* %17, i8 signext 63)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %12
%22 = load i8*, i8** %5
store i8* %22, i8** %4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
br label %26
23: ; preds = %12
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
br label %26
26: ; preds = %23, %21
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%28 = load i8*, i8** %5
%29 = load i8*, i8** %4
%30 = load i8*, i8** %4
%31 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29, i8* %30)
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%33 = call i32 @system(i8* %32)
store i32 %33, i32* %2
br label %34
34: ; preds = %26, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [48 x i8] c"man %s %s | rman -r \22man?%%s?%%s\22 -n %s -f html\00"
define i32 @http_rman(i8* %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 63)
%5 = icmp eq i8* %4, null
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %4
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 63)
%9 = icmp eq i8* %8, null
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = select i1 %9, i8* %7, i8* %10
%12 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %7
%13 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %11, i8* %11)
%14 = call i32 @system(i8* %3)
br label %15
15: ; preds = %1, %6
%16 = phi i32 [ %14, %6 ], [ -1, %1 ]
ret i32 %16
}