#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 */
unsigned int curposToXY(char const *const, unsigned int, unsigned int *,
                        unsigned int *);
int /*<<< orphan*/ goxy(unsigned int, unsigned int);
unsigned curposCalc(const char *const str_top, unsigned curpos, unsigned orgx,
                    unsigned orgy, int do_move) {
  unsigned x = orgx - 1, y = orgy - 1;
  unsigned rc;
  rc = curposToXY(str_top, curpos, &x, &y);
  if (do_move)
    goxy(x + 1, y + 1);
  return rc;
}


x86 assembly (clang, -O0):
<curposCalc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <curposToXY@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     117d <curposCalc+0x5d>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    -0x20(%rbp),%esi
add    $0x1,%esi
call   1030 <goxy@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curposCalc>:
push   %rbp
push   %rbx
push   %rax
mov    %r8d,%ebp
add    $0xffffffff,%edx
mov    %edx,0x4(%rsp)
add    $0xffffffff,%ecx
mov    %ecx,(%rsp)
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <curposToXY@plt>
mov    %eax,%ebx
test   %ebp,%ebp
je     1158 <curposCalc+0x38>
mov    0x4(%rsp),%edi
add    $0x1,%edi
mov    (%rsp),%esi
add    $0x1,%esi
call   1030 <goxy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @curposCalc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i32, i32* %8
%15 = sub i32 %14, 1
store i32 %15, i32* %11
%16 = load i32, i32* %9
%17 = sub i32 %16, 1
store i32 %17, i32* %12
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = call i32 @curposToXY(i8* %18, i32 %19, i32* %11, i32* %12)
store i32 %20, i32* %13
%21 = load i32, i32* %10
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %5
%24 = load i32, i32* %11
%25 = add i32 %24, 1
%26 = load i32, i32* %12
%27 = add i32 %26, 1
%28 = call i32 @goxy(i32 %25, i32 %27)
br label %29
29: ; preds = %23, %5
%30 = load i32, i32* %13
ret i32 %30
}

LLVM IR (-O2):
define i32 @curposCalc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
%9 = add i32 %2, -1
store i32 %9, i32* %6
%10 = bitcast i32* %7 to i8*
%11 = add i32 %3, -1
store i32 %11, i32* %7
%12 = call i32 @curposToXY(i8* %0, i32 %1, i32* %6, i32* %7)
%13 = icmp eq i32 %4, 0
br i1 %13, label %20, label %14
14: ; preds = %5
%15 = load i32, i32* %6
%16 = add i32 %15, 1
%17 = load i32, i32* %7
%18 = add i32 %17, 1
%19 = call i32 @goxy(i32 %16, i32 %18)
br label %20
20: ; preds = %14, %5
ret i32 %12
}