#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*/ addch(char);
int /*<<< orphan*/ smove(int *, int *);
void saddch(char c, int *posy, int *posx) {
  if (c == '\r' || c == '\n') {
    *posx = 0;
    *posy += 1;
    smove(posy, posx);
    return;
  }
  addch(c);
  *posx += 1;
  smove(posy, posx);
}


x86 assembly (clang, -O0):
<saddch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xd,%eax
je     1150 <saddch+0x30>
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jne    1177 <saddch+0x57>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <smove@plt>
jmp    1198 <saddch+0x78>
movsbl -0x1(%rbp),%edi
call   1030 <addch@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <smove@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saddch>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
cmp    $0xd,%dil
je     1136 <saddch+0x16>
cmp    $0xa,%dil
jne    1142 <saddch+0x22>
movl   $0x0,(%rbx)
addl   $0x1,(%r14)
jmp    114e <saddch+0x2e>
movsbl %dil,%edi
call   1030 <addch@plt>
addl   $0x1,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <smove@plt>

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

LLVM IR (-O2):
define void @saddch(i8 signext %0, i32* %1, i32* %2) {
switch i8 %0, label %8 [
i8 13, label %4
i8 10, label %4
]
4: ; preds = %3, %3
store i32 0, i32* %2
%5 = load i32, i32* %1
%6 = add nsw i32 %5, 1
store i32 %6, i32* %1
%7 = tail call i32 @smove(i32* %1, i32* %2)
br label %13
8: ; preds = %3
%9 = tail call i32 @addch(i8 signext %0)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
%12 = tail call i32 @smove(i32* %1, i32* %2)
br label %13
13: ; preds = %8, %4
ret void
}