#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int barco_pos(int n_barco) {
  int p;
  do {
    printf("Como deseas posicionar el barco %d?\n", n_barco);
    printf("[1] Vertical\n");
    printf("[2] Horizontal\n");
    printf("Opcion: ");
    scanf("%d", &p);
    printf("\n");
  } while (p != 1 && p != 2);
  return p;
}


x86 assembly (clang, -O0):
<barco_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     119d <barco_pos+0x7d>
cmpl   $0x2,-0x8(%rbp)
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    112b <barco_pos+0xb>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<barco_pos>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xedd(%rip),%r15
lea    0xee3(%rip),%r12
lea    0xec3(%rip),%r13
lea    0xec5(%rip),%rbp
lea    0x4(%rsp),%r14
xchg   %ax,%ax
lea    0xe89(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffe,%ecx
jb     1170 <barco_pos+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Como deseas posicionar el barco %d?\0A\00"
@.str.1 = [14 x i8] c"[1] Vertical\0A\00"
@.str.2 = [16 x i8] c"[2] Horizontal\0A\00"
@.str.3 = [9 x i8] c"Opcion: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @barco_pos(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %18, %1
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %12
12: ; preds = %4
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 2
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %4, label %20
20: ; preds = %18
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [37 x i8] c"Como deseas posicionar el barco %d?\0A\00"
@.str.3 = [9 x i8] c"Opcion: \00"
@.str.4 = [3 x i8] c"%d\00"
@str = [13 x i8] c"[1] Vertical\00"
@str.6 = [15 x i8] c"[2] Horizontal\00"
define i32 @barco_pos(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = call i32 @putchar(i32 10)
%11 = load i32, i32* %2
%12 = add i32 %11, -3
%13 = icmp ult i32 %12, -2
br i1 %13, label %4, label %14
14: ; preds = %4
ret i32 %11
}