#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*/ exit(int);
scalar_t__ get_int_flag(char ***, char, int *);
scalar_t__ get_str_flag(char ***, char, char **);
int normalize(int);
int /*<<< orphan*/ usage(char *, char *);
int /*<<< orphan*/ x11_set_desktop_name(int, char *);
char **do_rename(char **args) {
  int index = 0x80000000;
  char *name = NULL;
  while (*args) {
    if (args[0][0] != '-')
      break;
    if (get_int_flag(&args, 'i', &index)) {
    } else if (get_str_flag(&args, 'n', &name)) {
    } else
      usage("Unrecognized option to rename: %s\n", args[0]);
  }
  index = normalize(index);
  if (!x11_set_desktop_name(index, name))
    exit(1);
  return args;
}


x86 assembly (clang, -O0):
<do_rename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x80000000,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1200 <do_rename+0xa0>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11a1 <do_rename+0x41>
jmp    1200 <do_rename+0xa0>
lea    -0x8(%rbp),%rdi
mov    $0x69,%esi
lea    -0xc(%rbp),%rdx
call   1080 <get_int_flag@plt>
cmp    $0x0,%rax
je     11c2 <do_rename+0x62>
jmp    11fb <do_rename+0x9b>
lea    -0x8(%rbp),%rdi
mov    $0x6e,%esi
lea    -0x18(%rbp),%rdx
call   1040 <get_str_flag@plt>
cmp    $0x0,%rax
je     11e3 <do_rename+0x83>
jmp    11f6 <do_rename+0x96>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
call   1060 <usage@plt>
jmp    11fb <do_rename+0x9b>
jmp    117b <do_rename+0x1b>
mov    -0xc(%rbp),%edi
call   1050 <normalize@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <x11_set_desktop_name@plt>
cmp    $0x0,%eax
jne    122a <do_rename+0xca>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_rename>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
movl   $0x80000000,0x4(%rsp)
80
movq   $0x0,0x10(%rsp)
mov    (%rdi),%rax
test   %rax,%rax
je     1204 <do_rename+0xa4>
lea    0x8(%rsp),%rbx
lea    0x4(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe61(%rip),%r12
jmp    11bd <do_rename+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    (%rax),%rax
test   %rax,%rax
je     11fe <do_rename+0x9e>
cmpb   $0x2d,(%rax)
jne    11fe <do_rename+0x9e>
mov    %rbx,%rdi
mov    $0x69,%esi
mov    %r14,%rdx
call   1080 <get_int_flag@plt>
test   %rax,%rax
jne    11b0 <do_rename+0x50>
mov    %rbx,%rdi
mov    $0x6e,%esi
mov    %r15,%rdx
call   1040 <get_str_flag@plt>
test   %rax,%rax
jne    11b0 <do_rename+0x50>
mov    0x8(%rsp),%rax
mov    (%rax),%rsi
mov    %r12,%rdi
call   1060 <usage@plt>
jmp    11b0 <do_rename+0x50>
mov    0x4(%rsp),%edi
jmp    1209 <do_rename+0xa9>
mov    $0x80000000,%edi
call   1050 <normalize@plt>
mov    %eax,0x4(%rsp)
mov    0x10(%rsp),%rsi
mov    %eax,%edi
call   1030 <x11_set_desktop_name@plt>
test   %eax,%eax
je     1233 <do_rename+0xd3>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"Unrecognized option to rename: %s\0A\00"
define i8** @do_rename(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
store i8** %0, i8*** %2
store i32 -2147483648, i32* %3
store i8* null, i8** %4
br label %5
5: ; preds = %32, %1
%6 = load i8**, i8*** %2
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %33
9: ; preds = %5
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 45
br i1 %16, label %17, label %18
17: ; preds = %9
br label %33
18: ; preds = %9
%19 = call i64 @get_int_flag(i8*** %2, i8 signext 105, i32* %3)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %32
22: ; preds = %18
%23 = call i64 @get_str_flag(i8*** %2, i8 signext 110, i8** %4)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
br label %31
26: ; preds = %22
%27 = load i8**, i8*** %2
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @usage(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %26, %25
br label %32
32: ; preds = %31, %21
br label %5
33: ; preds = %17, %5
%34 = load i32, i32* %3
%35 = call i32 @normalize(i32 %34)
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = load i8*, i8** %4
%38 = call i32 @x11_set_desktop_name(i32 %36, i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %33
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %33
%43 = load i8**, i8*** %2
ret i8** %43
}

LLVM IR (-O2):
@.str = [35 x i8] c"Unrecognized option to rename: %s\0A\00"
define i8** @do_rename(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
store i8** %0, i8*** %2
%5 = bitcast i32* %3 to i8*
store i32 -2147483648, i32* %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = load i8*, i8** %0
%8 = icmp eq i8* %7, null
br i1 %8, label %29, label %9
9: ; preds = %1, %23
%10 = phi i8* [ %25, %23 ], [ %7, %1 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = call i64 @get_int_flag(i8*** %2, i8 signext 105, i32* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i64 @get_str_flag(i8*** %2, i8 signext 110, i8** %4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8**, i8*** %2
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16, %13
%24 = load i8**, i8*** %2
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %9
27: ; preds = %9, %23
%28 = load i32, i32* %3
br label %29
29: ; preds = %27, %1
%30 = phi i32 [ %28, %27 ], [ -2147483648, %1 ]
%31 = call i32 @normalize(i32 %30)
store i32 %31, i32* %3
%32 = load i8*, i8** %4
%33 = call i32 @x11_set_desktop_name(i32 %31, i8* %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %29
%38 = load i8**, i8*** %2
ret i8** %38
}