#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 pobjednik(char **, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int i, j, redovi, stupci, rezultat;
  char ploca[10][10] = {{}};
  scanf("%d%d", &redovi, &stupci);
  for (i = 0; i < redovi; i++) {
    for (j = 0; j < stupci; j++) {
      scanf(" %c", &ploca[i][j]);
    }
  }
  rezultat = pobjednik(ploca, redovi, stupci);
  if (rezultat == 0)
    printf("Nema pobjednika");
  if (rezultat == 1)
    printf("Pobjednik: x");
  if (rezultat == 2)
    printf("Pobjednik: o");
  if (rezultat == 3)
    printf("Nemoguca situacija");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xe97(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e3 <main+0xa3>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d0 <main+0x90>
movslq -0x8(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0xa,%rax,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <main+0x52>
jmp    11d5 <main+0x95>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117f <main+0x3f>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <pobjednik@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    120b <main+0xcb>
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1221 <main+0xe1>
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x18(%rbp)
jne    1237 <main+0xf7>
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3,-0x18(%rbp)
jne    124d <main+0x10d>
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe95(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
test   %esi,%esi
jle    11e2 <main+0xb2>
lea    0x10(%rsp),%r12
lea    0xe71(%rip),%r14
xor    %r15d,%r15d
jmp    11b0 <main+0x80>
nopl   0x0(%rax)
add    $0x1,%r15
movslq %esi,%rax
add    $0xa,%r12
cmp    %rax,%r15
jge    11e2 <main+0xb2>
test   %edx,%edx
jle    11a0 <main+0x70>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rdx
cmp    %rdx,%rbx
jl     11c0 <main+0x90>
mov    0xc(%rsp),%esi
jmp    11a0 <main+0x70>
lea    0x10(%rsp),%rdi
call   1040 <pobjednik@plt>
cmp    $0x3,%eax
ja     1206 <main+0xd6>
cltq
lea    0xe4e(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [16 x i8] c"Nema pobjednika\00"
@.str.3 = [13 x i8] c"Pobjednik: x\00"
@.str.4 = [13 x i8] c"Pobjednik: o\00"
@.str.5 = [19 x i8] c"Nemoguca situacija\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x [10 x i8]]
store i32 0, i32* %1
%8 = bitcast [10 x [10 x i8]]* %7 to i8*
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
store i32 0, i32* %2
br label %10
10: ; preds = %31, %0
%11 = load i32, i32* %2
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
store i32 0, i32* %3
br label %15
15: ; preds = %27, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %7, i64 0, i64 %21
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 %24
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %15
30: ; preds = %15
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %10
34: ; preds = %10
%35 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %7, i64 0, i64 0
%36 = bitcast [10 x i8]* %35 to i8**
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = call i32 @pobjednik(i8** %36, i32 %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %34
%43 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %34
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = load i32, i32* %6
%56 = icmp eq i32 %55, 3
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %57, %54
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [16 x i8] c"Nema pobjednika\00"
@.str.3 = [13 x i8] c"Pobjednik: x\00"
@.str.4 = [13 x i8] c"Pobjednik: o\00"
@.str.5 = [19 x i8] c"Nemoguca situacija\00"
@reltable.main = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x [10 x i8]]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %3, i64 0, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
%10 = load i32, i32* %2
br i1 %9, label %11, label %32
11: ; preds = %0, %26
%12 = phi i32 [ %27, %26 ], [ %8, %0 ]
%13 = phi i32 [ %28, %26 ], [ %10, %0 ]
%14 = phi i64 [ %29, %26 ], [ 0, %0 ]
%15 = icmp sgt i32 %13, 0
br i1 %15, label %16, label %26
16: ; preds = %11, %16
%17 = phi i64 [ %20, %16 ], [ 0, %11 ]
%18 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %3, i64 0, i64 %14, i64 %17
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16
%25 = load i32, i32* %1
br label %26
26: ; preds = %24, %11
%27 = phi i32 [ %25, %24 ], [ %12, %11 ]
%28 = phi i32 [ %21, %24 ], [ %13, %11 ]
%29 = add nuw nsw i64 %14, 1
%30 = sext i32 %27 to i64
%31 = icmp slt i64 %29, %30
br i1 %31, label %11, label %32
32: ; preds = %26, %0
%33 = phi i32 [ %10, %0 ], [ %28, %26 ]
%34 = phi i32 [ %8, %0 ], [ %27, %26 ]
%35 = bitcast [10 x [10 x i8]]* %3 to i8**
%36 = call i32 @pobjednik(i8** %35, i32 %34, i32 %33)
%37 = icmp ult i32 %36, 4
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = sext i32 %36 to i64
%40 = shl i64 %39, 2
%41 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.main to i8*), i64 %40)
%42 = call i32 @printf(i8* dereferenceable(1) %41)
br label %43
43: ; preds = %32, %38
ret i32 0
}