#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 atoi(char *);
int /*<<< orphan*/ error_msg(char *, char *);
scalar_t__ redo(int);
int /*<<< orphan*/ unselect();
void cmd_redo(const char *pf, char **args) {
  int change_id = 0;
  if (args[0]) {
    change_id = atoi(args[0]);
    if (change_id <= 0) {
      error_msg("Invalid change id: %s", args[0]);
      return;
    }
  }
  if (redo(change_id)) {
    unselect();
  }
}


x86 assembly (clang, -O0):
<cmd_redo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     119b <cmd_redo+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1196 <cmd_redo+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
call   1030 <error_msg@plt>
jmp    11b4 <cmd_redo+0x74>
jmp    119b <cmd_redo+0x5b>
mov    -0x14(%rbp),%edi
call   1040 <redo@plt>
cmp    $0x0,%rax
je     11b4 <cmd_redo+0x74>
mov    $0x0,%al
call   1050 <unselect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_redo>:
push   %rbx
mov    (%rsi),%rbx
test   %rbx,%rbx
je     1167 <cmd_redo+0x27>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
test   %eax,%eax
jg     1169 <cmd_redo+0x29>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <error_msg@plt>
xor    %edi,%edi
call   1040 <redo@plt>
test   %rax,%rax
je     117b <cmd_redo+0x3b>
xor    %eax,%eax
pop    %rbx
jmp    1050 <unselect@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Invalid change id: %s\00"
define void @cmd_redo(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 0, i32* %5
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @error_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %29
22: ; preds = %10
br label %23
23: ; preds = %22, %2
%24 = load i32, i32* %5
%25 = call i64 @redo(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @unselect()
br label %29
29: ; preds = %17, %27, %23
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Invalid change id: %s\00"
define void @cmd_redo(i8* nocapture readnone %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @atoi(i8* %3)
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @error_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %16
10: ; preds = %5, %2
%11 = phi i32 [ %6, %5 ], [ 0, %2 ]
%12 = tail call i64 @redo(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 (...) @unselect()
br label %16
16: ; preds = %10, %14, %8
ret void
}