#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*/ ispisi(int, int, int);
int /*<<< orphan*/ izadji_iz_ko(int, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ udji_u_ko(int, int);
void *dretva(void *x) {
  int i = *((int *)x);
  int k, m;
  for (k = 1; k <= 5; k++) {
    udji_u_ko(i, !i);
    for (m = 1; m <= 5; m++) {
      ispisi(i, k, m);
      sleep(1);
    }
    izadji_iz_ko(i, !i);
  }
}


x86 assembly (clang, -O0):
<dretva>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jg     11d7 <dretva+0x97>
mov    -0x14(%rbp),%edi
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1060 <udji_u_ko@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jg     11b3 <dretva+0x73>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1183 <dretva+0x43>
mov    -0x14(%rbp),%edi
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1040 <izadji_iz_ko@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <dretva+0x1c>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dretva>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%ebx
xor    %r14d,%r14d
test   %ebx,%ebx
sete   %r14b
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r14d,%esi
call   1060 <udji_u_ko@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x2,%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x3,%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x4,%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x5,%edx
call   1030 <ispisi@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <izadji_iz_ko@plt>
add    $0x1,%ebp
cmp    $0x6,%ebp
jne    1160 <dretva+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @dretva(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
store i32 %9, i32* %4
store i32 1, i32* %5
br label %10
10: ; preds = %39, %1
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 5
br i1 %12, label %13, label %42
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
%19 = call i32 @udji_u_ko(i32 %14, i32 %18)
store i32 1, i32* %6
br label %20
20: ; preds = %29, %13
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 5
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 @ispisi(i32 %24, i32 %25, i32 %26)
%28 = call i32 @sleep(i32 1)
br label %29
29: ; preds = %23
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %20
32: ; preds = %20
%33 = load i32, i32* %4
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
%37 = zext i1 %36 to i32
%38 = call i32 @izadji_iz_ko(i32 %33, i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %10
42: ; preds = %10
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
define noalias i8* @dretva(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
br label %6
6: ; preds = %1, %6
%7 = phi i32 [ 1, %1 ], [ %20, %6 ]
%8 = tail call i32 @udji_u_ko(i32 %3, i32 %5)
%9 = tail call i32 @ispisi(i32 %3, i32 %7, i32 1)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @ispisi(i32 %3, i32 %7, i32 2)
%12 = tail call i32 @sleep(i32 1)
%13 = tail call i32 @ispisi(i32 %3, i32 %7, i32 3)
%14 = tail call i32 @sleep(i32 1)
%15 = tail call i32 @ispisi(i32 %3, i32 %7, i32 4)
%16 = tail call i32 @sleep(i32 1)
%17 = tail call i32 @ispisi(i32 %3, i32 %7, i32 5)
%18 = tail call i32 @sleep(i32 1)
%19 = tail call i32 @izadji_iz_ko(i32 %3, i32 %5)
%20 = add nuw nsw i32 %7, 1
%21 = icmp eq i32 %20, 6
br i1 %21, label %22, label %6
22: ; preds = %6
ret i8* undef
}